doc/en/fixture.rst: chdir back to previous directory
This is considered to be best practice, and should be used in docs therefore.
This commit is contained in:
parent
6b13379f37
commit
83451b548f
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue