test_two_identities_in_one_file_are_still_distinguishable¶
Tests › tests/test_disambiguation.py
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
db = tmp_path / "onefile.db"conn = sqlite3.connect(str(db))
5 more
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 ); """ )conn.execute("INSERT INTO path (rowid, name) VALUES (1, 'pkg/both.py')")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"), ], )conn.commit()conn.close()
When
first = q.resolve_symbol(db, "harvest", "pkg.both.First.harvest")second = q.resolve_symbol(db, "harvest", "pkg.both.Second.harvest")
Then
- ✓ first is not None
- ✓ second is not None
- ✓ (first.rowid, first.line_start) equals (1, 10)
- ✓ (second.rowid, second.line_start) equals (2, 30)
- ✓ 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
… 23 steps between
… 20 steps between
… 105 steps between
… 31 later steps
3 more
- Build this wiki from the index · 7 of 400 steps
- clew — `main` (clew/cli.py) · 3 of 400 steps
- `main` (scripts/export_parity.py) · 3 of 203 steps
tests/test_disambiguation.py:320 · its file's page
What it checks (4)
assert first is not None and second is not Noneobservesresolve_symbolviafirstassert (first.rowid, first.line_start) == (1, 10)observesresolve_symbolviafirstassert (second.rowid, second.line_start) == (2, 30)observesresolve_symbolviasecondassert first.file == second.file == "pkg/both.py", "same file — only the identity differs"observesresolve_symbolviafirst
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
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.
Also reaches 4 requirements
Its run touches their code; that is reach, not proof.
- REQ-DDB-INDEX-004 measured
- REQ-DDB-QUERY-001 measured
- REQ-DDB-QUERY-003 measured
- REQ-DDB-QUERY-010 measured