Skip to content

Commit c6c4af2

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 0c1e79b commit c6c4af2

File tree

2 files changed

+60
-11
lines changed

2 files changed

+60
-11
lines changed

ci/check_requires_coverage.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@
1111

1212
import argparse
1313
import json
14-
import sys
1514
from collections import defaultdict
15+
from collections.abc import Iterable
1616
from pathlib import Path
17-
from typing import Iterable
1817

1918
_SKIP_PREFIX = "Skipped: "
2019

@@ -54,7 +53,9 @@ def _skip_reason(longrepr: object) -> str | None:
5453
return reason
5554

5655

57-
def collect_reportlog_data(reportlogs: Iterable[Path]) -> dict[str, dict[str, set[str]]]:
56+
def collect_reportlog_data(
57+
reportlogs: Iterable[Path],
58+
) -> dict[str, dict[str, set[str]]]:
5859
"""Return per-nodeid execution and skip information."""
5960
data: dict[str, dict[str, set[str]]] = defaultdict(
6061
lambda: {"call_outcomes": set(), "skip_reasons": set()}
@@ -136,7 +137,9 @@ def main(argv: list[str] | None = None) -> int:
136137
print(f"- {nodeid}: {', '.join(sorted(reasons))}")
137138
return 1
138139

139-
print(f"Checked {len(reportlogs)} report-log file(s); no uncovered requires tests found.")
140+
print(
141+
f"Checked {len(reportlogs)} report-log file(s); no uncovered requires tests found."
142+
)
140143
return 0
141144

142145

ci/test_check_requires_coverage.py

Lines changed: 53 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,20 @@ def test_uncovered_requires_test_is_reported(tmp_path: Path) -> None:
1515
reportlog = _write_reportlog(
1616
tmp_path / "reportlog.jsonl",
1717
[
18-
{"$report_type": "TestReport", "nodeid": "test_mod.py::test_gpu", "when": "setup", "outcome": "skipped", "longrepr": ["test_mod.py", 12, "Skipped: requires foo"]},
19-
{"$report_type": "TestReport", "nodeid": "test_mod.py::test_gpu", "when": "teardown", "outcome": "passed", "longrepr": None},
18+
{
19+
"$report_type": "TestReport",
20+
"nodeid": "test_mod.py::test_gpu",
21+
"when": "setup",
22+
"outcome": "skipped",
23+
"longrepr": ["test_mod.py", 12, "Skipped: requires foo"],
24+
},
25+
{
26+
"$report_type": "TestReport",
27+
"nodeid": "test_mod.py::test_gpu",
28+
"when": "teardown",
29+
"outcome": "passed",
30+
"longrepr": None,
31+
},
2032
],
2133
)
2234

@@ -29,15 +41,39 @@ def test_requires_test_is_covered_if_it_runs_elsewhere(tmp_path: Path) -> None:
2941
reportlog_a = _write_reportlog(
3042
tmp_path / "a.jsonl",
3143
[
32-
{"$report_type": "TestReport", "nodeid": "test_mod.py::test_optional", "when": "setup", "outcome": "skipped", "longrepr": ["test_mod.py", 12, "Skipped: requires foo"]},
44+
{
45+
"$report_type": "TestReport",
46+
"nodeid": "test_mod.py::test_optional",
47+
"when": "setup",
48+
"outcome": "skipped",
49+
"longrepr": ["test_mod.py", 12, "Skipped: requires foo"],
50+
},
3351
],
3452
)
3553
reportlog_b = _write_reportlog(
3654
tmp_path / "b.jsonl",
3755
[
38-
{"$report_type": "TestReport", "nodeid": "test_mod.py::test_optional", "when": "setup", "outcome": "passed", "longrepr": None},
39-
{"$report_type": "TestReport", "nodeid": "test_mod.py::test_optional", "when": "call", "outcome": "passed", "longrepr": None},
40-
{"$report_type": "TestReport", "nodeid": "test_mod.py::test_optional", "when": "teardown", "outcome": "passed", "longrepr": None},
56+
{
57+
"$report_type": "TestReport",
58+
"nodeid": "test_mod.py::test_optional",
59+
"when": "setup",
60+
"outcome": "passed",
61+
"longrepr": None,
62+
},
63+
{
64+
"$report_type": "TestReport",
65+
"nodeid": "test_mod.py::test_optional",
66+
"when": "call",
67+
"outcome": "passed",
68+
"longrepr": None,
69+
},
70+
{
71+
"$report_type": "TestReport",
72+
"nodeid": "test_mod.py::test_optional",
73+
"when": "teardown",
74+
"outcome": "passed",
75+
"longrepr": None,
76+
},
4177
],
4278
)
4379

@@ -48,7 +84,17 @@ def test_requires_skip_reason_allowlist_is_respected(tmp_path: Path) -> None:
4884
reportlog = _write_reportlog(
4985
tmp_path / "reportlog.jsonl",
5086
[
51-
{"$report_type": "TestReport", "nodeid": "test_mod.py::test_ros3", "when": "setup", "outcome": "skipped", "longrepr": ["test_mod.py", 12, "Skipped: requires h5netcdf>=1.3.0 and h5py with ros3 support"]},
87+
{
88+
"$report_type": "TestReport",
89+
"nodeid": "test_mod.py::test_ros3",
90+
"when": "setup",
91+
"outcome": "skipped",
92+
"longrepr": [
93+
"test_mod.py",
94+
12,
95+
"Skipped: requires h5netcdf>=1.3.0 and h5py with ros3 support",
96+
],
97+
},
5298
],
5399
)
54100

0 commit comments

Comments
 (0)