Merge pull request #6550 from blueyed/doc-cleandir-cd-back

doc/en/fixture.rst: chdir back to previous directory
This commit is contained in:
Daniel Hahler 2020-01-24 23:41:08 +01:00 committed by GitHub
commit 040a61e22c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -1042,11 +1042,13 @@ file:
import pytest
@pytest.fixture()
@pytest.fixture
def cleandir():
old_cwd = os.getcwd()
newpath = tempfile.mkdtemp()
os.chdir(newpath)
yield
os.chdir(old_cwd)
shutil.rmtree(newpath)
and declare its use in a test module via a ``usefixtures`` marker: