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

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-001measuredtest_an_exempt_status_is_listed_not_counted_as_a_gap → analyze_coverage → covered_via → read_catalog_at → git_text → git_argv
REQ-DDB-CONFIG-009measuredtest_an_exempt_status_is_listed_not_counted_as_a_gap → analyze_coverage → collect_tagged_functions → find_source_files → gate_exclusion
REQ-DDB-GUARD-011measuredtest_an_exempt_status_is_listed_not_counted_as_a_gap → analyze_coverage → load_requirements_full
REQ-DDB-GUARD-012measuredtest_an_exempt_status_is_listed_not_counted_as_a_gap → _config → load_config
REQ-DDB-GUARD-013measuredtest_an_exempt_status_is_listed_not_counted_as_a_gap → analyze_coverage → collect_tagged_functions → find_source_files
REQ-DDB-GUARD-016measuredtest_an_exempt_status_is_listed_not_counted_as_a_gap → analyze_coverage → load_requirements_full → _get_requirements_config → resolve_contained_path
REQ-DDB-GUARD-018measuredtest_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-019measuredtest_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-020measuredtest_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-021inferredtest_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-022measuredtest_an_exempt_status_is_listed_not_counted_as_a_gap → analyze_coverage
REQ-DDB-GUARD-024inferredtest_an_exempt_status_is_listed_not_counted_as_a_gap → _config → load_config → apply_opt_in_languages
REQ-DDB-GUARD-025measuredtest_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-027inferredtest_an_exempt_status_is_listed_not_counted_as_a_gap → analyze_coverage → covered_via → read_catalog_at
REQ-DDB-PIPE-011measuredtest_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-015inferredtest_an_exempt_status_is_listed_not_counted_as_a_gap → analyze_coverage → covered_via → _realised → link_ids
REQ-DDB-WIKI-054inferredtest_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
lines 62–62monkeypatch.chdir(tmp_path)lines 63–63config = _config(tmp_path, _CATALOG, ["planned", "configuration"])lines 64–64report = analyze_coverage(["src"], config)lines 65–65assert report["uncovered"] == ["REQ-A-004"]lines 68–71assert report["exempt"] == [ {"req_id": "REQ-A-002", "status": "planned", "reason": "x-status: planned"}, {"req_id": "REQ-A-003", "status": "configuration", "reason": "x-status: configuration"}, ]lines 72–72assert run_coverage(["src"], config) == 1

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

Show on the map →

Called by none

Calls _config, run_coverage

Checks

  • assert run_coverage(["src"], config) == 0
  • assert "REQ-A-002" in out and "planned" in out and "REQ-A-003" in out

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-001measuredtest_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-009measuredtest_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-011measuredtest_with_every_gap_exempt_the_gate_passes_and_still_names_them → run_coverage → analyze_coverage → load_requirements_full
REQ-DDB-GUARD-012measuredtest_with_every_gap_exempt_the_gate_passes_and_still_names_them → _config → load_config
REQ-DDB-GUARD-013measuredtest_with_every_gap_exempt_the_gate_passes_and_still_names_them → run_coverage → analyze_coverage → collect_tagged_functions → find_source_files
REQ-DDB-GUARD-016measuredtest_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-018measuredtest_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-019measuredtest_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-020measuredtest_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-021inferredtest_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-022measuredtest_with_every_gap_exempt_the_gate_passes_and_still_names_them → run_coverage
REQ-DDB-GUARD-024inferredtest_with_every_gap_exempt_the_gate_passes_and_still_names_them → _config → load_config → apply_opt_in_languages
REQ-DDB-GUARD-025measuredtest_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-027inferredtest_with_every_gap_exempt_the_gate_passes_and_still_names_them → run_coverage → analyze_coverage → covered_via → read_catalog_at
REQ-DDB-PIPE-011measuredtest_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-015inferredtest_with_every_gap_exempt_the_gate_passes_and_still_names_them → run_coverage → analyze_coverage → covered_via → _realised → link_ids
REQ-DDB-WIKI-054inferredtest_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
lines 79–79monkeypatch.chdir(tmp_path)lines 80–80catalog = _CATALOG.replace("REQ-A-004: {name: forgotten, x-status: implemented}", "")lines 81–81config = _config(tmp_path, catalog, ["planned", "configuration"])lines 82–82assert run_coverage(["src"], config) == 0lines 83–83out = capsys.readouterr().outlines 84–84assert "REQ-A-002" in out and "planned" in out and "REQ-A-003" in out

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

Show on the map →

Called by none

Calls _config, analyze_coverage

Checks

  • assert report["uncovered"] == ["REQ-A-002", "REQ-A-003", "REQ-A-004"]
  • assert report["exempt"] == []

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-001measuredtest_without_exempt_status_nothing_is_exempt → analyze_coverage → covered_via → read_catalog_at → git_text → git_argv
REQ-DDB-CONFIG-009measuredtest_without_exempt_status_nothing_is_exempt → analyze_coverage → collect_tagged_functions → find_source_files → gate_exclusion
REQ-DDB-GUARD-011measuredtest_without_exempt_status_nothing_is_exempt → analyze_coverage → load_requirements_full
REQ-DDB-GUARD-012measuredtest_without_exempt_status_nothing_is_exempt → _config → load_config
REQ-DDB-GUARD-013measuredtest_without_exempt_status_nothing_is_exempt → analyze_coverage → collect_tagged_functions → find_source_files
REQ-DDB-GUARD-016measuredtest_without_exempt_status_nothing_is_exempt → analyze_coverage → load_requirements_full → _get_requirements_config → resolve_contained_path
REQ-DDB-GUARD-018measuredtest_without_exempt_status_nothing_is_exempt → analyze_coverage → collect_tagged_functions → _process_source_file → parse_source_file_with_content
REQ-DDB-GUARD-019measuredtest_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-020measuredtest_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-021inferredtest_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-022measuredtest_without_exempt_status_nothing_is_exempt → analyze_coverage
REQ-DDB-GUARD-024inferredtest_without_exempt_status_nothing_is_exempt → _config → load_config → apply_opt_in_languages
REQ-DDB-GUARD-025measuredtest_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-027inferredtest_without_exempt_status_nothing_is_exempt → analyze_coverage → covered_via → read_catalog_at
REQ-DDB-PIPE-011measuredtest_without_exempt_status_nothing_is_exempt → analyze_coverage → collect_tagged_functions → find_source_files → gate_exclusion → binary_file
REQ-DDB-SCHEMA-015inferredtest_without_exempt_status_nothing_is_exempt → analyze_coverage → covered_via → _realised → link_ids
REQ-DDB-WIKI-054inferredtest_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

Activity · 5 steps
lines 91–91monkeypatch.chdir(tmp_path)lines 92–92config = _config(tmp_path, _CATALOG, None)lines 93–93report = analyze_coverage(["src"], config)lines 94–94assert report["uncovered"] == ["REQ-A-002", "REQ-A-003", "REQ-A-004"]lines 95–95assert report["exempt"] == []