test_ast_member_rows_are_qualifier_verified_not_name_keyed

Tests › tests/integration/test_self_index.py

passed Passed in the packaged run.

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

  1. observed = _edges_by_source(self_index_db)
  2. conn = sqlite3.connect(str(self_index_db))
4 more
  1. 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()
  2. parser = SubstrateParser("python")
  3. package = Path(__file__).resolve().parents[2] / "clew"
  4. sites = 0
→

When

  1. 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

  1. ✓ observed.get(SOURCE_AST_MEMBER, 0) is at least MIN_AST_MEMBER
  2. ✓ set(confidences) is at most {"resolved"}
  3. ✓ ambiguous_names is greater than 0
  4. ✓ sites is greater than 100

tests/integration/test_self_index.py:161 · its file's page

What it checks (4)

  1. 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_source via observed
  2. assert 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 attributed
  3. assert 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 attributed
  4. assert 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_calls

What 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.

test_ast_member_rows_are_qualifier_verified_not_name_keyed · 4 checks_ast_harvest_callsis_python_treeREQ-DDB-PIPE-003 · measured
Also reaches 1 requirement

Its run touches their code; that is reach, not proof.