import os
import pytest


@pytest.fixture(autouse=True)
def ensure_chdir():
    x = os.getcwd()
    yield
    os.chdir(x)

@@ -73,17 +73,23 @@
 ():%0A    
-x
+old_dir
  = os.ge
@@ -103,14 +103,44 @@
     
-yield%0A
+try:%0A        yield%0A    finally:%0A    
     
@@ -148,11 +148,17 @@
 s.chdir(
-x
+old_dir
 )%0A

make sure we always go back to the old directory.