Skip to content

Commit ae401a8

Browse files
authored
Cleanup test output (#1024)
1 parent 0bea313 commit ae401a8

7 files changed

+23
-18
lines changed

Diff for: tests/test_docker.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
from .util import get_data, get_main_output, needs_docker, needs_singularity
99

1010
@needs_docker
11-
def test_docker_workflow():
11+
def test_docker_workflow(tmpdir):
1212
result_code, _, stderr = get_main_output(
13-
['--default-container', 'debian',
13+
['--default-container', 'debian', '--outdir', str(tmpdir),
1414
get_data("tests/wf/hello-workflow.cwl"), "--usermessage", "hello"])
1515
assert "completed success" in stderr
1616
assert result_code == 0

Diff for: tests/test_examples.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -786,11 +786,11 @@ def test_cid_file_w_prefix(tmpdir):
786786

787787

788788
@needs_docker
789-
def test_wf_without_container():
789+
def test_wf_without_container(tmpdir):
790790
test_file = "hello-workflow.cwl"
791791
with temp_dir("cwltool_cache") as cache_dir:
792792
error_code, _, stderr = get_main_output(
793-
["--cachedir", cache_dir,
793+
["--cachedir", cache_dir, "--outdir", str(tmpdir),
794794
get_data("tests/wf/" + test_file),
795795
"--usermessage",
796796
"hello"]
@@ -832,11 +832,12 @@ def test_compute_checksum():
832832

833833

834834
@needs_docker
835-
def test_no_compute_checksum():
835+
def test_no_compute_chcksum(tmpdir):
836836
test_file = "tests/wf/wc-tool.cwl"
837837
job_file = "tests/wf/wc-job.json"
838838
error_code, stdout, stderr = get_main_output(
839-
["--no-compute-checksum", get_data(test_file), get_data(job_file)])
839+
["--no-compute-checksum", "--outdir", str(tmpdir),
840+
get_data(test_file), get_data(job_file)])
840841
assert "completed success" in stderr
841842
assert error_code == 0
842843
assert "checksum" not in stdout

Diff for: tests/test_ext.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def test_listing_v1_1():
5454
assert main([get_data('tests/wf/listing_v1_1.cwl'), get_data('tests/listing-job.yml')]) != 0
5555

5656
@needs_docker
57-
def test_double_overwrite():
57+
def test_double_overwrite(tmpdir):
5858
try:
5959
tmp = tempfile.mkdtemp()
6060
tmp_name = os.path.join(tmp, "value")
@@ -64,7 +64,8 @@ def test_double_overwrite():
6464
with open(tmp_name, "w") as f:
6565
f.write(before_value)
6666

67-
assert main(["--enable-ext", get_data('tests/wf/mut2.cwl'), "-a", tmp_name]) == 0
67+
assert main(["--enable-ext", "--outdir", str(tmpdir),
68+
get_data('tests/wf/mut2.cwl'), "-a", tmp_name]) == 0
6869

6970
with open(tmp_name, "r") as f:
7071
actual_value = f.read()
@@ -192,8 +193,8 @@ def test_require_prefix_networkaccess():
192193
assert main(["--enable-ext", get_data('tests/wf/networkaccess-fail.cwl')]) != 0
193194

194195
@needs_docker
195-
def test_require_prefix_workreuse():
196-
assert main(["--enable-ext", get_data('tests/wf/workreuse.cwl')]) == 0
196+
def test_require_prefix_workreuse(tmpdir):
197+
assert main(["--enable-ext", '--outdir', str(tmpdir), get_data('tests/wf/workreuse.cwl')]) == 0
197198
assert main([get_data('tests/wf/workreuse.cwl')]) != 0
198199
assert main(["--enable-ext", get_data('tests/wf/workreuse-fail.cwl')]) != 0
199200

Diff for: tests/test_pack.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def _pack_idempotently(document):
122122

123123
@needs_docker
124124
@pytest.mark.parametrize('wf_path,job_path,namespaced', cwl_to_run)
125-
def test_packed_workflow_execution(wf_path, job_path, namespaced):
125+
def test_packed_workflow_execution(wf_path, job_path, namespaced, tmpdir):
126126
load_tool.loaders = {}
127127

128128
document_loader, workflowobj, uri = fetch_document(
@@ -142,8 +142,8 @@ def test_packed_workflow_execution(wf_path, job_path, namespaced):
142142
normal_output = StringIO()
143143
packed_output = StringIO()
144144

145-
normal_params = [get_data(wf_path), get_data(job_path)]
146-
packed_params = ['--debug', get_data(wf_packed_path), get_data(job_path)]
145+
normal_params = ['--outdir', str(tmpdir), get_data(wf_path), get_data(job_path)]
146+
packed_params = ['--outdir', str(tmpdir), '--debug', get_data(wf_packed_path), get_data(job_path)]
147147

148148
assert main(normal_params, stdout=normal_output) == 0
149149
assert main(packed_params, stdout=packed_output) == 0

Diff for: tests/test_parallel.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88

99

1010
@windows_needs_docker
11-
def test_sequential_workflow():
11+
def test_sequential_workflow(tmpdir):
1212
load_tool.loaders = {}
1313
test_file = "tests/wf/count-lines1-wf.cwl"
1414
executor = MultithreadedJobExecutor()
1515
runtime_context = RuntimeContext()
16+
runtime_context.outdir = str(tmpdir)
1617
runtime_context.select_resources = executor.select_resources
1718
factory = get_windows_safe_factory(
1819
executor=executor, runtime_context=runtime_context)

Diff for: tests/test_relax_path_checks.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
'''
2626

2727
@needs_docker
28-
def test_spaces_in_input_files():
28+
def test_spaces_in_input_files(tmpdir):
2929
try:
3030
script_file = NamedTemporaryFile(mode='w', delete=False)
3131
script_file.write(script)
@@ -35,7 +35,7 @@ def test_spaces_in_input_files():
3535
spaces = NamedTemporaryFile(prefix="test with spaces", delete=False)
3636
spaces.close()
3737

38-
params = ["--debug", script_file.name, '--input', spaces.name]
38+
params = ["--debug", "--outdir", str(tmpdir), script_file.name, '--input', spaces.name]
3939
assert main(params) == 1
4040
assert main(["--relax-path-checks"] + params) == 0
4141
finally:

Diff for: tests/test_toolargparse.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,15 @@
7878

7979
@needs_docker
8080
@pytest.mark.parametrize('name,script_contents,params', scripts_argparse_params)
81-
def test_argparse(name, script_contents, params):
81+
def test_argparse(name, script_contents, params, tmpdir):
8282
try:
8383
script = NamedTemporaryFile(mode='w', delete=False)
8484
script.write(script_contents)
8585
script.close()
8686

87-
assert main(params(script.name)) == 0, name
87+
my_params = ["--outdir", str(tmpdir)]
88+
my_params.extend(params(script.name))
89+
assert main(my_params) == 0, name
8890

8991
except SystemExit as err:
9092
assert err.code == 0, name

0 commit comments

Comments
 (0)