Skip to content

Commit 78adaf2

Browse files
committed
simplify env handling
1 parent 0812b3d commit 78adaf2

File tree

3 files changed

+15
-31
lines changed

3 files changed

+15
-31
lines changed

tests/test_pack.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def test_packed_workflow_execution(wf_path, job_path, namespaced, tmpdir):
154154
packed_output = StringIO()
155155

156156
normal_params = ['--outdir', str(tmpdir), get_data(wf_path), get_data(job_path)]
157-
packed_params = ['--outdir', str(tmpdir), '--debug', get_data(wf_packed_path), get_data(job_path)]
157+
packed_params = ['--outdir', str(tmpdir), '--debug', wf_packed_path, get_data(job_path)]
158158

159159
assert main(normal_params, stdout=normal_output) == 0
160160
assert main(packed_params, stdout=packed_output) == 0

tests/test_singularity.py

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import sys
2+
import copy
23
import os
34
import pytest
45

@@ -16,34 +17,17 @@
1617

1718
@needs_singularity
1819
def test_singularity_pullfolder(tmp_path):
19-
20-
if "SINGULARITY_PULLFOLDER" in os.environ:
21-
del os.environ["SINGULARITY_PULLFOLDER"]
22-
workdir = tmp_path / "working_dir_new"
23-
workdir.mkdir()
24-
os.chdir(str(workdir))
25-
pullfolder = tmp_path / "pull_folder"
26-
pullfolder.mkdir()
27-
os.environ["SINGULARITY_PULLFOLDER"] = str(pullfolder)
28-
if "SINGULARITY_PULLFOLDER" in os.environ:
29-
result_code, stdout, stderr = get_main_output(
30-
['--singularity', get_data("tests/sing_pullfolder_test.cwl"), "--message", "hello"])
31-
assert result_code == 0
32-
else:
33-
assert result_code != 0
34-
else:
35-
workdir = tmp_path / "working_dir_new"
36-
workdir.mkdir()
37-
os.chdir(str(workdir))
38-
pullfolder = tmp_path / "pullfolder"
39-
pullfolder.mkdir()
40-
os.environ["SINGULARITY_PULLFOLDER"] = str(pullfolder)
41-
if "SINGULARITY_PULLFOLDER" in os.environ:
42-
result_code, stdout, stderr = get_main_output(
43-
['--singularity', get_data("tests/sing_pullfolder_test.cwl"), "--message", "hello"])
44-
assert result_code == 0
45-
else:
46-
assert result_code != 0
20+
workdir = tmp_path / "working_dir_new"
21+
workdir.mkdir()
22+
os.chdir(str(workdir))
23+
pullfolder = tmp_path / "pullfolder"
24+
pullfolder.mkdir()
25+
env = copy.deepcopy(os.environ)
26+
env["SINGULARITY_PULLFOLDER"] = str(pullfolder)
27+
result_code, stdout, stderr = get_main_output(
28+
['--singularity', get_data("tests/sing_pullfolder_test.cwl"), "--message", "hello"], env=env)
29+
assert result_code == 0
30+
# TODO, confirm that the image is in the pullfolder
4731

4832
@needs_singularity
4933
def test_singularity_workflow(tmpdir):

tests/util.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ def get_data(filename):
6464
reason="Running this test on MS Windows requires the docker executable "
6565
"on the system path.")
6666

67-
def get_main_output(args):
67+
def get_main_output(args, env=None):
6868
process = subprocess.Popen(
6969
[sys.executable, "-m", "cwltool"] + args,
70-
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
70+
stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env)
7171

7272
stdout, stderr = process.communicate()
7373
return process.returncode, stdout.decode(), stderr.decode()

0 commit comments

Comments
 (0)