Skip to content

Commit 403fc20

Browse files
use proper tmpdir for jobfiles
1 parent f803e2c commit 403fc20

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

planemo/engine/interface.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import abc
44
import json
5-
import os
5+
import shutil
66
import tempfile
77
from typing import (
88
Callable,
@@ -97,23 +97,20 @@ def _collect_test_results(self, test_cases, test_timeout):
9797
def _run_test_cases(self, test_cases, test_timeout):
9898
runnables = [test_case.runnable for test_case in test_cases]
9999
job_paths = []
100-
tmp_paths = []
101100
output_collectors = []
101+
test_directory = tempfile.mkdtemp()
102102
for test_case in test_cases:
103103
if test_case.job_path is None:
104104
job = test_case.job
105105
with tempfile.NamedTemporaryFile(
106-
dir=test_case.tests_directory,
106+
dir=test_directory,
107107
suffix=".json",
108108
prefix="plnmotmptestjob",
109109
delete=False,
110110
mode="w+",
111111
) as f:
112-
tmp_path = f.name
113-
job_path = tmp_path
114-
tmp_paths.append(tmp_path)
115112
json.dump(job, f)
116-
job_paths.append(job_path)
113+
job_paths.append(f.name)
117114
else:
118115
job_paths.append(test_case.job_path)
119116
output_collectors.append(
@@ -122,8 +119,7 @@ def _run_test_cases(self, test_cases, test_timeout):
122119
try:
123120
run_responses = self._run(runnables, job_paths, output_collectors)
124121
finally:
125-
for tmp_path in tmp_paths:
126-
os.remove(tmp_path)
122+
shutil.rmtree(test_directory)
127123
return run_responses
128124

129125

0 commit comments

Comments
 (0)