Skip to content

Commit 369eddd

Browse files
committed
improve test failure reporting
1 parent 2697625 commit 369eddd

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

tests/test_examples.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -1120,8 +1120,9 @@ def test_cid_file_dir(tmp_path: Path, factor: str) -> None:
11201120
stderr = re.sub(r"\s\s+", " ", stderr)
11211121
assert "completed success" in stderr
11221122
assert error_code == 0
1123-
cidfiles_count = sum(1 for _ in tmp_path.glob("**/*"))
1124-
assert cidfiles_count == 2
1123+
cidfiles = list(tmp_path.glob("**/*"))
1124+
cidfiles_count = len(cidfiles)
1125+
assert cidfiles_count == 2, f"Should be 2 cidfiles, but got {cidfiles}"
11251126

11261127

11271128
@needs_docker
@@ -1180,7 +1181,8 @@ def test_cid_file_w_prefix(tmp_path: Path, factor: str) -> None:
11801181
error_code, stdout, stderr = get_main_output(commands)
11811182
finally:
11821183
listing = tmp_path.iterdir()
1183-
cidfiles_count = sum(1 for _ in tmp_path.glob("**/pytestcid*"))
1184+
cidfiles = tmp_path.glob("**/pytestcid*")
1185+
cidfiles_count = sum(1 for _ in cidfiles)
11841186
stderr = re.sub(r"\s\s+", " ", stderr)
11851187
assert "completed success" in stderr
11861188
assert error_code == 0

tests/test_iwdr.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,9 @@ def test_iwdr_permutations(tmp_path_factory: Any) -> None:
131131
)
132132
assert err_code == 0
133133
log = json.loads(stdout)["log"]
134-
assert log["checksum"] == "sha1$bc51ebb3f65ca44282789dd1e6de9747d8abe75f", log
134+
with open(log["path"]) as log_h:
135+
log_text = log_h.read()
136+
assert log["checksum"] == "sha1$bc51ebb3f65ca44282789dd1e6de9747d8abe75f", log_text
135137

136138

137139
def test_iwdr_permutations_readonly(tmp_path_factory: Any) -> None:
@@ -240,7 +242,9 @@ def test_iwdr_permutations_inplace(tmp_path_factory: Any) -> None:
240242
)
241243
assert err_code == 0
242244
log = json.loads(stdout)["log"]
243-
assert log["checksum"] == "sha1$bc51ebb3f65ca44282789dd1e6de9747d8abe75f", log
245+
with open(log["path"]) as log_h:
246+
log_text = log_h.read()
247+
assert log["checksum"] == "sha1$bc51ebb3f65ca44282789dd1e6de9747d8abe75f", log_text
244248

245249

246250
@needs_singularity
@@ -298,7 +302,9 @@ def test_iwdr_permutations_singularity(tmp_path_factory: Any) -> None:
298302
)
299303
assert err_code == 0
300304
log = json.loads(stdout)["log"]
301-
assert log["checksum"] == "sha1$bc51ebb3f65ca44282789dd1e6de9747d8abe75f", log
305+
with open(log["path"]) as log_h:
306+
log_text = log_h.read()
307+
assert log["checksum"] == "sha1$bc51ebb3f65ca44282789dd1e6de9747d8abe75f", log_text
302308

303309

304310
@needs_singularity

tests/test_udocker.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,16 @@ def test_udocker_usage_should_not_write_cid_file(udocker: str, tmp_path: Path) -
5050
"""Confirm that no cidfile is made when udocker is used."""
5151

5252
with working_directory(tmp_path):
53-
test_file = "tests/echo-position-expr.cwl"
54-
job_file = "tests/echo-position-echo-position-expr-job.yml"
53+
test_file = "tests/echo.cwl"
5554
error_code, stdout, stderr = get_main_output(
5655
[
5756
"--debug",
5857
"--default-container",
5958
"debian:stable-slim",
6059
"--user-space-docker-cmd=" + udocker,
6160
get_data(test_file),
62-
get_data(job_file),
61+
"--inp",
62+
"hello",
6363
]
6464
)
6565

0 commit comments

Comments
 (0)