test_req_test_scope.py

tests/test_req_test_scope.py

A covering test is a function in TEST CODE, as the index's test scope defines it (round 4, R9).

test_a_function_is_judged_by_its_body_s_file_not_a_declaration_s

None test_req_test_scope.test_a_function_is_judged_by_its_body_s_file_not_a_declaration_s(Path tmp_path)

The body's file decides.

tests/test_req_test_scope.py:75

Checks

  • assert _linked(db) == ["test_helper"]

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-SCHEMA-006measuredtest_a_function_is_judged_by_its_body_s_file_not_a_declaration_s → import_req_edges
Source · 25 lines
def test_a_function_is_judged_by_its_body_s_file_not_a_declaration_s(tmp_path: Path) -> None:
    """FOUND ON entropic (2.1, measuring clew#74): 34 of 39 covering-test rows were PRODUCTION
    functions — `extract_final_text`, bodied in src/facade/final_text.h, re-declared in
    tests/unit/api/final_text_test.cpp — because the test check read `file_id`, the declaring
    file. They were listed as covering tests AND dropped from their requirement's implementers.

    @brief The body's file decides.
    """
    db = tmp_path / "doxy.db"
    with sqlite3.connect(db) as conn:
        conn.executescript(
            """
            CREATE TABLE path (name TEXT);
            CREATE TABLE memberdef (rowid INTEGER PRIMARY KEY, kind TEXT, name TEXT,
                file_id INTEGER, bodyfile_id INTEGER, briefdescription TEXT,
                detaileddescription TEXT);
            INSERT INTO path (rowid, name) VALUES (1, 'tests/final_text_test.cpp'), (2, 'src/final_text.h');
            INSERT INTO memberdef VALUES
                (1, 'function', 'extract_final_text', 1, 2, '', '@req REQ-1'),
                (2, 'function', 'test_helper', 1, 1, '', '@req REQ-1');
            """
        )
    import_req_edges(db)
    import_req_test_edges(db, test_patterns=TEST_PATH_FACTS)
    assert _linked(db) == ["test_helper"]

1 more lines, not shown

Activity · 6 steps
lines 83–83db = tmp_path / "doxy.db"lines 84–84with sqlite3.connect(db) as connlines 85–96conn.executescript( """ CREATE TABLE path (name TEXT); CREATE TABLE memberdef (rowid INTEGER PRIMARY KEY, kind TEXT, name TEXT, file_id INTEGER, bodyfile_id INTEGER, briefdescription TEXT, detaileddescription TEXT); INSERT INTO path (rowid, name) VALUES (1, 'tests/final_text_test.cpp'), (2, 'src/final_text.h'); INSERT INTO memberdef VALUES (1, 'function', 'extract_final_text', 1, 2, '', '@req REQ-1'), (2, 'function', 'test_helper', 1, 1, '', '@req REQ-1'); """ )lines 97–97import_req_edges(db)lines 98–98import_req_test_edges(db, test_patterns=TEST_PATH_FACTS)lines 99–99assert _linked(db) == ["test_helper"]

test_with_test_patterns_only_functions_in_test_code_are_tests

None test_req_test_scope.test_with_test_patterns_only_functions_in_test_code_are_tests(Path tmp_path)

A `test`-substring path or a `test_` name outside test code is not a test.

tests/test_req_test_scope.py:59

Checks

  • assert _linked(db) == ["checks_foo", "test_marks_scope"]

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-SCHEMA-006measuredtest_with_test_patterns_only_functions_in_test_code_are_tests → import_req_edges
Source · 8 lines
def test_with_test_patterns_only_functions_in_test_code_are_tests(tmp_path: Path) -> None:
    """@brief A `test`-substring path or a `test_` name outside test code is not a test."""
    db = _db(tmp_path)
    import_req_edges(db)
    import_req_test_edges(db, test_patterns=TEST_PATH_FACTS)
    assert _linked(db) == ["checks_foo", "test_marks_scope"]

Activity · 4 steps
lines 61–61db = _db(tmp_path)lines 62–62import_req_edges(db)lines 63–63import_req_test_edges(db, test_patterns=TEST_PATH_FACTS)lines 64–64assert _linked(db) == ["checks_foo", "test_marks_scope"]

test_without_patterns_the_legacy_heuristic_still_applies

None test_req_test_scope.test_without_patterns_the_legacy_heuristic_still_applies(Path tmp_path)

Callers that pass no patterns keep the old behaviour (its own tests pin it).

tests/test_req_test_scope.py:67

Checks

  • assert "test_marks_scope" in _linked(db)

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-SCHEMA-006measuredtest_without_patterns_the_legacy_heuristic_still_applies → import_req_edges
Source · 8 lines
def test_without_patterns_the_legacy_heuristic_still_applies(tmp_path: Path) -> None:
    """@brief Callers that pass no patterns keep the old behaviour (its own tests pin it)."""
    db = _db(tmp_path)
    import_req_edges(db)
    import_req_test_edges(db)
    assert "test_marks_scope" in _linked(db)

Activity · 4 steps
lines 69–69db = _db(tmp_path)lines 70–70import_req_edges(db)lines 71–71import_req_test_edges(db)lines 72–72assert "test_marks_scope" in _linked(db)