Merge pull request #6550 from blueyed/doc-cleandir-cd-back
doc/en/fixture.rst: chdir back to previous directory
This commit is contained in:
commit
040a61e22c
|
@ -1042,11 +1042,13 @@ file:
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture()
|
@pytest.fixture
|
||||||
def cleandir():
|
def cleandir():
|
||||||
|
old_cwd = os.getcwd()
|
||||||
newpath = tempfile.mkdtemp()
|
newpath = tempfile.mkdtemp()
|
||||||
os.chdir(newpath)
|
os.chdir(newpath)
|
||||||
yield
|
yield
|
||||||
|
os.chdir(old_cwd)
|
||||||
shutil.rmtree(newpath)
|
shutil.rmtree(newpath)
|
||||||
|
|
||||||
and declare its use in a test module via a ``usefixtures`` marker:
|
and declare its use in a test module via a ``usefixtures`` marker:
|
||||||
|
|
Loading…
Reference in New Issue