File tree 1 file changed +10
-2
lines changed 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change 14
14
from tests .lib .venv import VirtualEnvironment
15
15
16
16
17
+ def pytest_addoption (parser ):
18
+ parser .addoption (
19
+ "--keep-tmpdir" , action = "store_true" ,
20
+ default = False , help = "keep temporary test directories"
21
+ )
22
+
23
+
17
24
def pytest_collection_modifyitems (items ):
18
25
for item in items :
19
26
if not hasattr (item , 'module' ): # e.g.: DoctestTextfile
@@ -50,7 +57,7 @@ def pytest_collection_modifyitems(items):
50
57
51
58
52
59
@pytest .yield_fixture
53
- def tmpdir (tmpdir ):
60
+ def tmpdir (request , tmpdir ):
54
61
"""
55
62
Return a temporary directory path object which is unique to each test
56
63
function invocation, created as a sub directory of the base temporary
@@ -65,7 +72,8 @@ def tmpdir(tmpdir):
65
72
# Clear out the temporary directory after the test has finished using it.
66
73
# This should prevent us from needing a multiple gigabyte temporary
67
74
# directory while running the tests.
68
- tmpdir .remove (ignore_errors = True )
75
+ if not request .config .getoption ("--keep-tmpdir" ):
76
+ tmpdir .remove (ignore_errors = True )
69
77
70
78
71
79
@pytest .fixture (autouse = True )
You can’t perform that action at this time.
0 commit comments