test_guard_coverage_exempt.py¶
tests/guard/test_guard_coverage_exempt.py
Requirement coverage, exempted by status and never silently (round 3, P6c-2).
test_an_exempt_status_is_listed_not_counted_as_a_gap
None test_guard_coverage_exempt.test_an_exempt_status_is_listed_not_counted_as_a_gap(Path tmp_path, pytest.MonkeyPatch monkeypatch)
planned and configuration are exempt, by id and status; the forgotten one is a gap.
tests/guard/test_guard_coverage_exempt.py:58
Checks
assert report["uncovered"] == ["REQ-A-004"]assert report["exempt"] == [assert run_coverage(["src"], config) == 1
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_an_exempt_status_is_listed_not_counted_as_a_gap → analyze_coverage → covered_via → read_catalog_at → git_text → git_argv |
| REQ-DDB-CONFIG-009 | measured | test_an_exempt_status_is_listed_not_counted_as_a_gap → analyze_coverage → collect_tagged_functions → find_source_files → gate_exclusion |
| REQ-DDB-GUARD-011 | measured | test_an_exempt_status_is_listed_not_counted_as_a_gap → analyze_coverage → load_requirements_full |
| REQ-DDB-GUARD-012 | measured | test_an_exempt_status_is_listed_not_counted_as_a_gap → _config → load_config |
| REQ-DDB-GUARD-013 | measured | test_an_exempt_status_is_listed_not_counted_as_a_gap → analyze_coverage → collect_tagged_functions → find_source_files |
| REQ-DDB-GUARD-016 | measured | test_an_exempt_status_is_listed_not_counted_as_a_gap → analyze_coverage → load_requirements_full → _get_requirements_config → resolve_contained_path |
| REQ-DDB-GUARD-018 | measured | test_an_exempt_status_is_listed_not_counted_as_a_gap → analyze_coverage → collect_tagged_functions → _process_source_file → parse_source_file_with_content |
| REQ-DDB-GUARD-019 | measured | test_an_exempt_status_is_listed_not_counted_as_a_gap → analyze_coverage → collect_tagged_functions → _process_source_file → parse_source_file_with_content → parse_content_for_file → parse_functions → parse_functions_ts → _collect_functions → _find_preceding_doxygen → parse_doxygen_tags |
| REQ-DDB-GUARD-020 | measured | test_an_exempt_status_is_listed_not_counted_as_a_gap → analyze_coverage → collect_tagged_functions → _process_source_file → parse_source_file_with_content → parse_content_for_file → language_for_file |
| REQ-DDB-GUARD-021 | inferred | test_an_exempt_status_is_listed_not_counted_as_a_gap → analyze_coverage → collect_tagged_functions → _process_source_file → parse_source_file_with_content → parse_content_for_file → parse_functions → parse_functions_ts → _collect_functions → _find_preceding_doxygen → _find_python_docstring_block |
| REQ-DDB-GUARD-022 | measured | test_an_exempt_status_is_listed_not_counted_as_a_gap → analyze_coverage |
| REQ-DDB-GUARD-024 | inferred | test_an_exempt_status_is_listed_not_counted_as_a_gap → _config → load_config → apply_opt_in_languages |
| REQ-DDB-GUARD-025 | measured | test_an_exempt_status_is_listed_not_counted_as_a_gap → analyze_coverage → collect_tagged_functions → _process_source_file → parse_source_file_with_content → parse_content_for_file → parse_functions → parse_functions_ts → _collect_functions → _js_returns_void |
| REQ-DDB-GUARD-027 | inferred | test_an_exempt_status_is_listed_not_counted_as_a_gap → analyze_coverage → covered_via → read_catalog_at |
| REQ-DDB-PIPE-011 | measured | test_an_exempt_status_is_listed_not_counted_as_a_gap → analyze_coverage → collect_tagged_functions → find_source_files → gate_exclusion → binary_file |
| REQ-DDB-SCHEMA-015 | inferred | test_an_exempt_status_is_listed_not_counted_as_a_gap → analyze_coverage → covered_via → _realised → link_ids |
| REQ-DDB-WIKI-054 | inferred | test_an_exempt_status_is_listed_not_counted_as_a_gap → analyze_coverage → collect_tagged_functions → find_source_files → gate_exclusion → _gate_matcher → load_toolchain_config → _string_list → all |
Source · 17 lines
def test_an_exempt_status_is_listed_not_counted_as_a_gap(
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
) -> None:
"""@brief planned and configuration are exempt, by id and status; the forgotten one is a gap."""
monkeypatch.chdir(tmp_path)
config = _config(tmp_path, _CATALOG, ["planned", "configuration"])
report = analyze_coverage(["src"], config)
assert report["uncovered"] == ["REQ-A-004"]
## SPEC WIDENED, ADDITIVE (2.1, #72 item 14): each exempt row also says WHY (`reason`), since a
## field (`exempt_when`) can exempt as well as the status. The listed rows are unchanged.
assert report["exempt"] == [
{"req_id": "REQ-A-002", "status": "planned", "reason": "x-status: planned"},
{"req_id": "REQ-A-003", "status": "configuration", "reason": "x-status: configuration"},
]
assert run_coverage(["src"], config) == 1
Activity · 6 steps
test_with_every_gap_exempt_the_gate_passes_and_still_names_them
None test_guard_coverage_exempt.test_with_every_gap_exempt_the_gate_passes_and_still_names_them(Path tmp_path, pytest.MonkeyPatch monkeypatch, pytest.CaptureFixture[str] capsys)
Exit 0, and the text report still lists each exemption.
tests/guard/test_guard_coverage_exempt.py:75
Checks
assert run_coverage(["src"], config) == 0assert "REQ-A-002" in out and "planned" in out and "REQ-A-003" in out
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_with_every_gap_exempt_the_gate_passes_and_still_names_them → run_coverage → analyze_coverage → covered_via → read_catalog_at → git_text → git_argv |
| REQ-DDB-CONFIG-009 | measured | test_with_every_gap_exempt_the_gate_passes_and_still_names_them → run_coverage → analyze_coverage → collect_tagged_functions → find_source_files → gate_exclusion |
| REQ-DDB-GUARD-011 | measured | test_with_every_gap_exempt_the_gate_passes_and_still_names_them → run_coverage → analyze_coverage → load_requirements_full |
| REQ-DDB-GUARD-012 | measured | test_with_every_gap_exempt_the_gate_passes_and_still_names_them → _config → load_config |
| REQ-DDB-GUARD-013 | measured | test_with_every_gap_exempt_the_gate_passes_and_still_names_them → run_coverage → analyze_coverage → collect_tagged_functions → find_source_files |
| REQ-DDB-GUARD-016 | measured | test_with_every_gap_exempt_the_gate_passes_and_still_names_them → run_coverage → analyze_coverage → load_requirements_full → _get_requirements_config → resolve_contained_path |
| REQ-DDB-GUARD-018 | measured | test_with_every_gap_exempt_the_gate_passes_and_still_names_them → run_coverage → analyze_coverage → collect_tagged_functions → _process_source_file → parse_source_file_with_content |
| REQ-DDB-GUARD-019 | measured | test_with_every_gap_exempt_the_gate_passes_and_still_names_them → run_coverage → analyze_coverage → collect_tagged_functions → _process_source_file → parse_source_file_with_content → parse_content_for_file → parse_functions → parse_functions_ts → _collect_functions → _find_preceding_doxygen → parse_doxygen_tags |
| REQ-DDB-GUARD-020 | measured | test_with_every_gap_exempt_the_gate_passes_and_still_names_them → run_coverage → analyze_coverage → collect_tagged_functions → _process_source_file → parse_source_file_with_content → parse_content_for_file → language_for_file |
| REQ-DDB-GUARD-021 | inferred | test_with_every_gap_exempt_the_gate_passes_and_still_names_them → run_coverage → analyze_coverage → collect_tagged_functions → _process_source_file → parse_source_file_with_content → parse_content_for_file → parse_functions → parse_functions_ts → _collect_functions → _find_preceding_doxygen → _find_python_docstring_block |
| REQ-DDB-GUARD-022 | measured | test_with_every_gap_exempt_the_gate_passes_and_still_names_them → run_coverage |
| REQ-DDB-GUARD-024 | inferred | test_with_every_gap_exempt_the_gate_passes_and_still_names_them → _config → load_config → apply_opt_in_languages |
| REQ-DDB-GUARD-025 | measured | test_with_every_gap_exempt_the_gate_passes_and_still_names_them → run_coverage → analyze_coverage → collect_tagged_functions → _process_source_file → parse_source_file_with_content → parse_content_for_file → parse_functions → parse_functions_ts → _collect_functions → _js_returns_void |
| REQ-DDB-GUARD-027 | inferred | test_with_every_gap_exempt_the_gate_passes_and_still_names_them → run_coverage → analyze_coverage → covered_via → read_catalog_at |
| REQ-DDB-PIPE-011 | measured | test_with_every_gap_exempt_the_gate_passes_and_still_names_them → run_coverage → analyze_coverage → collect_tagged_functions → find_source_files → gate_exclusion → binary_file |
| REQ-DDB-SCHEMA-015 | inferred | test_with_every_gap_exempt_the_gate_passes_and_still_names_them → run_coverage → analyze_coverage → covered_via → _realised → link_ids |
| REQ-DDB-WIKI-054 | inferred | test_with_every_gap_exempt_the_gate_passes_and_still_names_them → run_coverage → analyze_coverage → collect_tagged_functions → find_source_files → gate_exclusion → _gate_matcher → load_toolchain_config → _string_list → all |
Source · 12 lines
def test_with_every_gap_exempt_the_gate_passes_and_still_names_them(
tmp_path: Path, monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str]
) -> None:
"""@brief Exit 0, and the text report still lists each exemption."""
monkeypatch.chdir(tmp_path)
catalog = _CATALOG.replace("REQ-A-004: {name: forgotten, x-status: implemented}", "")
config = _config(tmp_path, catalog, ["planned", "configuration"])
assert run_coverage(["src"], config) == 0
out = capsys.readouterr().out
assert "REQ-A-002" in out and "planned" in out and "REQ-A-003" in out
Activity · 6 steps
test_without_exempt_status_nothing_is_exempt
None test_guard_coverage_exempt.test_without_exempt_status_nothing_is_exempt(Path tmp_path, pytest.MonkeyPatch monkeypatch)
No declaration, no exemption: every untagged requirement is uncovered.
tests/guard/test_guard_coverage_exempt.py:87
Checks
assert report["uncovered"] == ["REQ-A-002", "REQ-A-003", "REQ-A-004"]assert report["exempt"] == []
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_without_exempt_status_nothing_is_exempt → analyze_coverage → covered_via → read_catalog_at → git_text → git_argv |
| REQ-DDB-CONFIG-009 | measured | test_without_exempt_status_nothing_is_exempt → analyze_coverage → collect_tagged_functions → find_source_files → gate_exclusion |
| REQ-DDB-GUARD-011 | measured | test_without_exempt_status_nothing_is_exempt → analyze_coverage → load_requirements_full |
| REQ-DDB-GUARD-012 | measured | test_without_exempt_status_nothing_is_exempt → _config → load_config |
| REQ-DDB-GUARD-013 | measured | test_without_exempt_status_nothing_is_exempt → analyze_coverage → collect_tagged_functions → find_source_files |
| REQ-DDB-GUARD-016 | measured | test_without_exempt_status_nothing_is_exempt → analyze_coverage → load_requirements_full → _get_requirements_config → resolve_contained_path |
| REQ-DDB-GUARD-018 | measured | test_without_exempt_status_nothing_is_exempt → analyze_coverage → collect_tagged_functions → _process_source_file → parse_source_file_with_content |
| REQ-DDB-GUARD-019 | measured | test_without_exempt_status_nothing_is_exempt → analyze_coverage → collect_tagged_functions → _process_source_file → parse_source_file_with_content → parse_content_for_file → parse_functions → parse_functions_ts → _collect_functions → _find_preceding_doxygen → parse_doxygen_tags |
| REQ-DDB-GUARD-020 | measured | test_without_exempt_status_nothing_is_exempt → analyze_coverage → collect_tagged_functions → _process_source_file → parse_source_file_with_content → parse_content_for_file → language_for_file |
| REQ-DDB-GUARD-021 | inferred | test_without_exempt_status_nothing_is_exempt → analyze_coverage → collect_tagged_functions → _process_source_file → parse_source_file_with_content → parse_content_for_file → parse_functions → parse_functions_ts → _collect_functions → _find_preceding_doxygen → _find_python_docstring_block |
| REQ-DDB-GUARD-022 | measured | test_without_exempt_status_nothing_is_exempt → analyze_coverage |
| REQ-DDB-GUARD-024 | inferred | test_without_exempt_status_nothing_is_exempt → _config → load_config → apply_opt_in_languages |
| REQ-DDB-GUARD-025 | measured | test_without_exempt_status_nothing_is_exempt → analyze_coverage → collect_tagged_functions → _process_source_file → parse_source_file_with_content → parse_content_for_file → parse_functions → parse_functions_ts → _collect_functions → _js_returns_void |
| REQ-DDB-GUARD-027 | inferred | test_without_exempt_status_nothing_is_exempt → analyze_coverage → covered_via → read_catalog_at |
| REQ-DDB-PIPE-011 | measured | test_without_exempt_status_nothing_is_exempt → analyze_coverage → collect_tagged_functions → find_source_files → gate_exclusion → binary_file |
| REQ-DDB-SCHEMA-015 | inferred | test_without_exempt_status_nothing_is_exempt → analyze_coverage → covered_via → _realised → link_ids |
| REQ-DDB-WIKI-054 | inferred | test_without_exempt_status_nothing_is_exempt → analyze_coverage → collect_tagged_functions → find_source_files → gate_exclusion → _gate_matcher → load_toolchain_config → _string_list → all |
Source · 9 lines
def test_without_exempt_status_nothing_is_exempt(
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
) -> None:
"""@brief No declaration, no exemption: every untagged requirement is uncovered."""
monkeypatch.chdir(tmp_path)
config = _config(tmp_path, _CATALOG, None)
report = analyze_coverage(["src"], config)
assert report["uncovered"] == ["REQ-A-002", "REQ-A-003", "REQ-A-004"]
assert report["exempt"] == []1 more lines, not shown