Skip to content

Commit 83451b5

Browse files
committed
doc/en/fixture.rst: chdir back to previous directory
This is considered to be best practice, and should be used in docs therefore.
1 parent 6b13379 commit 83451b5

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

doc/en/fixture.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1042,11 +1042,13 @@ file:
10421042
import pytest
10431043
10441044
1045-
@pytest.fixture()
1045+
@pytest.fixture
10461046
def cleandir():
1047+
old_cwd = os.getcwd()
10471048
newpath = tempfile.mkdtemp()
10481049
os.chdir(newpath)
10491050
yield
1051+
os.chdir(old_cwd)
10501052
shutil.rmtree(newpath)
10511053
10521054
and declare its use in a test module via a ``usefixtures`` marker:

0 commit comments

Comments
 (0)