From 6cd61390c260055c3637c7a0c08e74a75f31a3cd Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Fri, 20 Dec 2019 13:18:49 -0800 Subject: [PATCH] Improve docs so regen doesn't leak temp directories --- doc/en/fixture.rst | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/doc/en/fixture.rst b/doc/en/fixture.rst index 08305a5cc..db06a4015 100644 --- a/doc/en/fixture.rst +++ b/doc/en/fixture.rst @@ -1035,15 +1035,19 @@ file: # content of conftest.py - import pytest - import tempfile import os + import shutil + import tempfile + + import pytest @pytest.fixture() def cleandir(): newpath = tempfile.mkdtemp() os.chdir(newpath) + yield + shutil.rmtree(newpath) and declare its use in a test module via a ``usefixtures`` marker: