test_two_identities_in_one_file_are_still_distinguishable

Tests › tests/test_disambiguation.py

passed Passed in the packaged run.

What this test is for

Why it exists

WHY THE SELECTOR IS NOT THE `file` SUBSTRING `Candidate` used to promise. Two classes in one module, each with a `harvest`, is ordinary Python — and a file substring cannot separate them, so it would have resolved gh#37's motivating example and failed the general case.

Given

  1. db = tmp_path / "onefile.db"
  2. conn = sqlite3.connect(str(db))
5 more
  1. conn.executescript( """ CREATE TABLE path (name TEXT); CREATE TABLE memberdef ( rowid INTEGER PRIMARY KEY, kind TEXT, name TEXT, file_id INTEGER, bodyfile_id INTEGER, bodystart INTEGER, bodyend INTEGER, definition TEXT, argsstring TEXT, briefdescription TEXT, detaileddescription TEXT, static INTEGER ); """ )
  2. conn.execute("INSERT INTO path (rowid, name) VALUES (1, 'pkg/both.py')")
  3. conn.executemany( "INSERT INTO memberdef (rowid, kind, name, file_id, bodyfile_id, bodystart, bodyend, " "definition, argsstring, briefdescription, detaileddescription, static) " "VALUES (?, 'function', 'harvest', 1, 1, ?, ?, ?, '(self)', '', '', 0)", [ (1, 10, 20, "Any pkg.both.First.harvest"), (2, 30, 40, "Any pkg.both.Second.harvest"), ], )
  4. conn.commit()
  5. conn.close()
→

When

  1. first = q.resolve_symbol(db, "harvest", "pkg.both.First.harvest")
  2. second = q.resolve_symbol(db, "harvest", "pkg.both.Second.harvest")
→

Then

  1. ✓ first is not None
  2. ✓ second is not None
  3. ✓ (first.rowid, first.line_start) equals (1, 10)
  4. ✓ (second.rowid, second.line_start) equals (2, 30)
  5. ✓ first.file == second.file == "pkg/both.py" holds

What it exercises

The parts of the system's flows this test ran, measured by per-test coverage: lit steps ran in this test, dimmed ones did not, and ▶ marks where the test called in. Each title opens the whole flow with these steps lit.

Look up one name: everything the index holds about it · 13 of 226 steps

… 17 earlier steps

callercallercallercallerclew/query/_common.pyclew/query/_common.pyclew/query/_common.pyclew/query/_common.pyclew/query/recovery.pyclew/query/recovery.pyclew/query/recovery.pyclew/query/recovery.pydossier18. _documentation_mentions → table_exists18table_exists19. _documentation_mentions → has_columns19has_columns20. has_columns → table_exists20table_exists21–22. _hint_from → _name_exists21_name_exists +1 more

… 23 steps between

callercallercallercallerclew/query/payload.pyclew/query/payload.pyclew/query/payload.pyclew/query/payload.pyclew/query/_common.pyclew/query/_common.pyclew/query/_common.pyclew/query/_common.pyother filesother filesother filesother filesloop (line 515)loopdossier46. _ambiguity_counts → table_exists46table_exists47. _ambiguity_counts → function_candidates47function_candidates48. function_candidates → table_exists48table_exists▶ test enters49–53. function_candidates → _test_scope_term49_test_scope_term +4 more54. resolve_selector → _ends_at_boundary54_ends_at_boundary55. matching_identity → qualified_name_of55qualified_name_of56. _flatten_subject → _gate_definitions56_gate_definitions57. _gate_definitions → macro_definitions57macro_definitions

… 20 steps between

callercallercallercallerclew/query/payload.pyclew/query/payload.pyclew/query/payload.pyclew/query/payload.pyclew/query/_common.pyclew/query/_common.pyclew/query/_common.pyclew/query/_common.pyother filesother filesother filesother filesdossier78. _referenced_by → table_exists78table_exists79. _macro_def → symbol_provenance79symbol_provenance80–81. symbol_provenance → records_provenance80records_provenance +1 more82. _gate_definitions → _gate_definition_gaps82_gate_definition_gaps83. _flatten_subject → _empty_callers_note83_empty_callers_note

… 105 steps between

callercallercallercallerclew/query/_common.pyclew/query/_common.pyclew/query/_common.pyclew/query/_common.pyclew/query/traversal.pyclew/query/traversal.pyclew/query/traversal.pyclew/query/traversal.pydossier189. chain_trace → function_candidates189function_candidates190. chain_trace → candidate_rows190candidate_rows191. candidate_rows → symbol_provenance191symbol_provenance▶ test enters192–193. candidate_rows → qualified_name_of192qualified_name_of +1 more194. chain_trace → is_overloaded194is_overloaded195. chain_trace → _make_node195_make_node

… 31 later steps

3 more

tests/test_disambiguation.py:320 · its file's page

What it checks (4)

  1. assert first is not None and second is not None observes resolve_symbol via first
  2. assert (first.rowid, first.line_start) == (1, 10) observes resolve_symbol via first
  3. assert (second.rowid, second.line_start) == (2, 30) observes resolve_symbol via second
  4. assert first.file == second.file == "pkg/both.py", "same file — only the identity differs" observes resolve_symbol via first

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_two_identities_in_one_file_are_still_distinguishable→resolve_symbol

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_two_identities_in_one_file_are_still_distinguishable · 4 checksresolve_symbolsymbol_provenanceREQ-DDB-INDEX-004 · measuredresolve_symbolconnectREQ-DDB-QUERY-001 · measuredresolve_symbolREQ-DDB-QUERY-003 · measuredresolve_symbolREQ-DDB-QUERY-010 · measured
Also reaches 4 requirements

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