File tree 4 files changed +24
-1
lines changed
4 files changed +24
-1
lines changed Original file line number Diff line number Diff line change
1
+ Create temp_dir if not exists - by :user: `q0w `.
Original file line number Diff line number Diff line change 172
172
173
173
.. conf ::
174
174
:keys: temp_dir
175
- :default: {tox_root}/.temp
175
+ :default: {tox_root}/.tmp
176
176
177
177
Directory where to put tox temporary files. For example: we create a hard link (if possible, otherwise new copy) in
178
178
this directory for the project package. This ensures tox works correctly when having parallel runs (as each session
Original file line number Diff line number Diff line change @@ -288,6 +288,7 @@ def _setup_env(self) -> None:
288
288
if eq is False and old is not None : # pragma: no branch # recreate if already created and not equals
289
289
raise Recreate (f"env type changed from { old } to { conf } " )
290
290
self ._handle_env_tmp_dir ()
291
+ self ._handle_core_tmp_dir ()
291
292
292
293
def _setup_with_env (self ) -> None : # noqa: B027 # empty abstract base class
293
294
pass
@@ -303,6 +304,9 @@ def _handle_env_tmp_dir(self) -> None:
303
304
ensure_empty_dir (env_tmp_dir )
304
305
env_tmp_dir .mkdir (parents = True , exist_ok = True )
305
306
307
+ def _handle_core_tmp_dir (self ) -> None :
308
+ self .core ["temp_dir" ].mkdir (parents = True , exist_ok = True )
309
+
306
310
def _clean (self , transitive : bool = False ) -> None : # noqa: U100
307
311
if self ._run_state ["clean" ]: # pragma: no branch
308
312
return # pragma: no cover
Original file line number Diff line number Diff line change
1
+ from pathlib import Path
2
+
3
+ from tox .pytest import ToxProjectCreator
4
+
5
+
6
+ def test_ensure_temp_dir_exists (tox_project : ToxProjectCreator ) -> None :
7
+ ini = "[testenv]\n commands=python -c 'import os; os.path.exists(r\" {temp_dir}\" )'"
8
+ project = tox_project ({"tox.ini" : ini })
9
+ result = project .run ()
10
+ result .assert_success ()
11
+
12
+
13
+ def test_dont_cleanup_temp_dir (tox_project : ToxProjectCreator , tmp_path : Path ) -> None :
14
+ (tmp_path / "foo" / "bar" ).mkdir (parents = True )
15
+ project = tox_project ({"tox.ini" : "[tox]\n temp_dir=foo" })
16
+ result = project .run ()
17
+ result .assert_success ()
18
+ assert (tmp_path / "foo" / "bar" ).exists ()
You can’t perform that action at this time.
0 commit comments