Skip to content

Commit 0f70992

Browse files
committed
less random files left over after tests
1 parent 12993a6 commit 0f70992

File tree

7 files changed

+93
-32
lines changed

7 files changed

+93
-32
lines changed

tests/test_cuda.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from unittest.mock import MagicMock
2+
13
import mock
24
import pytest
35
from schema_salad.avro import schema
@@ -17,8 +19,6 @@
1719

1820
from .util import get_data, needs_docker, needs_singularity_3_or_newer
1921

20-
from unittest.mock import MagicMock
21-
2222
cuda_version = cuda_version_and_device_count()
2323

2424

tests/test_dependencies.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,22 @@
1818

1919
@needs_docker
2020
@pytest.mark.skipif(not deps, reason="galaxy-tool-util is not installed")
21-
def test_biocontainers() -> None:
21+
def test_biocontainers(tmp_path: Path) -> None:
2222
wflow = get_data("tests/seqtk_seq.cwl")
2323
job = get_data("tests/seqtk_seq_job.json")
24-
error_code, _, _ = get_main_output(["--beta-use-biocontainers", wflow, job])
24+
error_code, _, _ = get_main_output(
25+
["--outdir", str(tmp_path), "--beta-use-biocontainers", wflow, job]
26+
)
2527

2628
assert error_code == 0
2729

2830

2931
@pytest.mark.skipif(not deps, reason="galaxy-tool-util is not installed")
30-
def test_bioconda() -> None:
32+
def test_bioconda(tmp_path: Path) -> None:
3133
wflow = get_data("tests/seqtk_seq.cwl")
3234
job = get_data("tests/seqtk_seq_job.json")
3335
error_code, _, stderr = get_main_output(
34-
["--beta-conda-dependencies", "--debug", wflow, job]
36+
["--outdir", str(tmp_path), "--beta-conda-dependencies", "--debug", wflow, job]
3537
)
3638

3739
assert error_code == 0, stderr

tests/test_docker.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,14 @@ def test_docker_file_mount() -> None:
7373

7474

7575
@needs_docker
76-
def test_docker_strict_cpu_limit() -> None:
76+
def test_docker_strict_cpu_limit(tmp_path: Path) -> None:
7777
result_code, stdout, stderr = get_main_output(
7878
[
7979
"--strict-cpu-limit",
8080
"--default-container",
8181
"docker.io/debian:stable-slim",
82+
"--outdir",
83+
str(tmp_path),
8284
get_data("tests/wf/cores_float.cwl"),
8385
]
8486
)
@@ -88,12 +90,14 @@ def test_docker_strict_cpu_limit() -> None:
8890

8991

9092
@needs_docker
91-
def test_docker_strict_memory_limit() -> None:
93+
def test_docker_strict_memory_limit(tmp_path: Path) -> None:
9294
result_code, stdout, stderr = get_main_output(
9395
[
9496
"--strict-memory-limit",
9597
"--default-container",
9698
"docker.io/debian:stable-slim",
99+
"--outdir",
100+
str(tmp_path),
97101
get_data("tests/wf/storage_float.cwl"),
98102
]
99103
)
@@ -103,11 +107,13 @@ def test_docker_strict_memory_limit() -> None:
103107

104108

105109
@needs_docker
106-
def test_docker_strict_cpu_limit_warning() -> None:
110+
def test_docker_strict_cpu_limit_warning(tmp_path: Path) -> None:
107111
result_code, stdout, stderr = get_main_output(
108112
[
109113
"--default-container",
110114
"docker.io/debian:stable-slim",
115+
"--outdir",
116+
str(tmp_path),
111117
get_data("tests/wf/cores_float.cwl"),
112118
]
113119
)
@@ -117,11 +123,13 @@ def test_docker_strict_cpu_limit_warning() -> None:
117123

118124

119125
@needs_docker
120-
def test_docker_strict_memory_limit_warning() -> None:
126+
def test_docker_strict_memory_limit_warning(tmp_path: Path) -> None:
121127
result_code, stdout, stderr = get_main_output(
122128
[
123129
"--default-container",
124130
"docker.io/debian:stable-slim",
131+
"--outdir",
132+
str(tmp_path),
125133
get_data("tests/wf/storage_float.cwl"),
126134
]
127135
)

tests/test_examples.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,7 +1188,7 @@ def test_cid_file_w_prefix(tmp_path: Path, factor: str) -> None:
11881188

11891189
@needs_docker
11901190
@pytest.mark.parametrize("factor", test_factors)
1191-
def test_secondary_files_v1_1(factor: str) -> None:
1191+
def test_secondary_files_v1_1(factor: str, tmp_path: Path) -> None:
11921192
test_file = "secondary-files.cwl"
11931193
test_job_file = "secondary-files-job.yml"
11941194
try:
@@ -1197,14 +1197,16 @@ def test_secondary_files_v1_1(factor: str) -> None:
11971197
commands.extend(
11981198
[
11991199
"--debug",
1200+
"--outdir",
1201+
str(tmp_path),
12001202
get_data(os.path.join("tests", test_file)),
12011203
get_data(os.path.join("tests", test_job_file)),
12021204
]
12031205
)
12041206
error_code, _, stderr = get_main_output(commands)
12051207
finally:
12061208
# 664 in octal, '-rw-rw-r--'
1207-
assert stat.S_IMODE(os.stat("lsout").st_mode) == 436
1209+
assert stat.S_IMODE(os.stat(tmp_path / "lsout").st_mode) == 436
12081210
os.umask(old_umask) # revert back to original umask
12091211
stderr = re.sub(r"\s\s+", " ", stderr)
12101212
assert "completed success" in stderr
@@ -1213,13 +1215,15 @@ def test_secondary_files_v1_1(factor: str) -> None:
12131215

12141216
@needs_docker
12151217
@pytest.mark.parametrize("factor", test_factors)
1216-
def test_secondary_files_bad_v1_1(factor: str) -> None:
1218+
def test_secondary_files_bad_v1_1(factor: str, tmp_path: Path) -> None:
12171219
"""Affirm the correct error message for a bad secondaryFiles expression."""
12181220
test_file = "secondary-files-bad.cwl"
12191221
test_job_file = "secondary-files-job.yml"
12201222
commands = factor.split()
12211223
commands.extend(
12221224
[
1225+
"--outdir",
1226+
str(tmp_path),
12231227
get_data(os.path.join("tests", test_file)),
12241228
get_data(os.path.join("tests", test_job_file)),
12251229
]
@@ -1706,10 +1710,10 @@ def test_record_default_with_long() -> None:
17061710
)
17071711

17081712

1709-
def test_record_outputeval() -> None:
1713+
def test_record_outputeval(tmp_path: Path) -> None:
17101714
"""Confirm that record types can be populated from outputEval."""
17111715
tool_path = get_data("tests/wf/record_outputeval.cwl")
1712-
err_code, stdout, stderr = get_main_output([tool_path])
1716+
err_code, stdout, stderr = get_main_output(["--outdir", str(tmp_path), tool_path])
17131717
assert err_code == 0
17141718
result = json.loads(stdout)["references"]
17151719
assert "genome_fa" in result

tests/test_procgenerator.py

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""ProcessGenerator related tests."""
22

3+
from pathlib import Path
34

45
import pytest
56

@@ -8,21 +9,34 @@
89
from .util import get_data
910

1011

11-
def test_missing_enable_ext(monkeypatch: pytest.MonkeyPatch) -> None:
12+
def test_missing_enable_ext(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
1213
"""Test missing enable-ext option fails.
1314
1415
Check that a workflow that needs `--enable-ext` and
1516
`--enable-dev` fails without those options and passes with them.
1617
"""
1718
monkeypatch.delenv("CWLTOOL_OPTIONS", raising=False)
18-
assert main([get_data("tests/wf/generator/zing.cwl"), "--zing", "zipper"]) == 1
19+
assert (
20+
main(
21+
[
22+
"--outdir",
23+
str(tmp_path),
24+
get_data("tests/wf/generator/zing.cwl"),
25+
"--zing",
26+
"zipper",
27+
]
28+
)
29+
== 1
30+
)
1931

2032
assert (
2133
main(
2234
[
2335
"--debug",
2436
"--enable-ext",
2537
"--enable-dev",
38+
"--outdir",
39+
str(tmp_path),
2640
get_data("tests/wf/generator/zing.cwl"),
2741
"--zing",
2842
"zipper",
@@ -32,4 +46,15 @@ def test_missing_enable_ext(monkeypatch: pytest.MonkeyPatch) -> None:
3246
)
3347

3448
monkeypatch.setenv("CWLTOOL_OPTIONS", "--enable-ext --enable-dev")
35-
assert main([get_data("tests/wf/generator/zing.cwl"), "--zing", "zipper"]) == 0
49+
assert (
50+
main(
51+
[
52+
"--outdir",
53+
str(tmp_path),
54+
get_data("tests/wf/generator/zing.cwl"),
55+
"--zing",
56+
"zipper",
57+
]
58+
)
59+
== 0
60+
)

tests/test_relocate.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313

1414

1515
@needs_docker
16-
def test_for_910() -> None:
17-
assert main([get_data("tests/wf/910.cwl")]) == 0
18-
assert main([get_data("tests/wf/910.cwl")]) == 0
16+
def test_for_910(tmp_path: Path) -> None:
17+
assert main(["--outdir", str(tmp_path), get_data("tests/wf/910.cwl")]) == 0
18+
assert main(["--outdir", str(tmp_path), get_data("tests/wf/910.cwl")]) == 0
1919

2020

2121
@needs_docker

0 commit comments

Comments
 (0)