From 83451b548fc3c86d17275e7a3b12e4238167aea3 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Thu, 23 Jan 2020 19:08:32 +0100 Subject: [PATCH] doc/en/fixture.rst: chdir back to previous directory This is considered to be best practice, and should be used in docs therefore. --- doc/en/fixture.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/en/fixture.rst b/doc/en/fixture.rst index db06a4015..2094027f3 100644 --- a/doc/en/fixture.rst +++ b/doc/en/fixture.rst @@ -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: