test_ast_member_rows_are_qualifier_verified_not_name_keyed¶
Tests › tests/integration/test_self_index.py
What this test is for
Why it exists
THE SUCCESSOR TO "MUST BE ZERO" (gh#362 -> gh#21), and the reason the assertion had to change SHAPE rather than get a new number.
Given
observed = _edges_by_source(self_index_db)conn = sqlite3.connect(str(self_index_db))
4 more
try: confidences = dict( conn.execute( "SELECT confidence, COUNT(*) FROM call_edges WHERE source=? GROUP BY confidence", (SOURCE_AST_MEMBER,), ) ) ambiguous_names = conn.execute( "SELECT COUNT(*) FROM call_edges ce JOIN memberdef m ON m.rowid = ce.callee_rowid " "WHERE ce.source = ? AND (SELECT COUNT(*) FROM memberdef m2 " "WHERE m2.name = m.name AND m2.kind = 'function') > 1", (SOURCE_AST_MEMBER,), ).fetchone()[0] finally: conn.close()parser = SubstrateParser("python")package = Path(__file__).resolve().parents[2] / "clew"sites = 0
When
for source_file in sorted(package.rglob("*.py")): src = source_file.read_bytes() for site in _ast_harvest_calls(parser.parse(src), src): sites += int(len(site) > 2 and site[2] == SOURCE_AST_MEMBER)
Then
- ✓ observed.get(SOURCE_AST_MEMBER, 0) is at least MIN_AST_MEMBER
- ✓ set(confidences) is at most {"resolved"}
- ✓ ambiguous_names is greater than 0
- ✓ sites is greater than 100
tests/integration/test_self_index.py:161 · its file's page
What it checks (4)
assert observed.get(SOURCE_AST_MEMBER, 0) >= MIN_AST_MEMBER, ( f"{observed.get(SOURCE_AST_MEMBER, 0)} ast_member row(s) on this index, floor " f"{MIN_AST_MEMBER}. `self.method()` carries its enclosing class as a qualifier " "(gh#21), so a collapse to zero means that stopped being emitted." )observes_edges_by_sourceviaobservedassert set(confidences) <= {"resolved"}, ( f"ast_member rows are not all resolved: {confidences}. A fuzzy row here means the " "qualifier left several candidates and something emitted them regardless." )not attributedassert ambiguous_names > 0, ( "every ast_member edge has a callee whose name is unique in the index, so a " "name-keyed rule could have produced all of them and this test proves nothing. " "The qualifier's whole value is picking among SAME-NAMED candidates." )not attributedassert sites > 100, ( f"only {sites} ast_member call site(s) harvested from {package.name}/ — the " "walker has stopped recognising member calls, so a thin ast_member layer would be " "a BROKEN HARVEST rather than the resolution rule. Measured 2521 sites at the time " "this was written; the threshold is deliberately far below that, " "because the claim is 'the harvest is alive', not a count." )not attributed
Where the product reaches it
No product flow reaches this code: no product entry point's flow calls any of the functions this test calls.
Call flow
test_ast_member_rows_are_qualifier_verified_not_name_keyed→_edges_by_source→_ast_harvest_callsWhat it reaches
Each row runs from this test, through the calls it makes, to the code a requirement names. If that code breaks, the test's checks are what should catch it. Reaching is not proving: a check only proves what it observes. No mutation records were given, so these rows say what the test REACHES.
Also reaches 1 requirement
Its run touches their code; that is reach, not proof.
- REQ-DDB-PIPE-003 measured