test_search_matches_file_path.py¶
tests/test_search_matches_file_path.py
A symbol was in the index and no natural query could find it.
test_a_name_match_still_outranks_a_path_match
None test_search_matches_file_path.test_a_name_match_still_outranks_a_path_match(Path loader_db)
A name match must still outrank a mere path match.
tests/test_search_matches_file_path.py:123
Checks
assert names.index("loader_unrelated") < names.index("_candidate_paths"), (f"a path match outranked a name match, which would bury named symbols: {names}" )
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-INDEX-004 | measured | |
| REQ-DDB-QUERY-001 | measured | |
| REQ-DDB-QUERY-003 | measured | |
| REQ-DDB-QUERY-007 | measured | |
| REQ-DDB-QUERY-012 | measured |
Source · 15 lines
def test_a_name_match_still_outranks_a_path_match(loader_db: Path) -> None:
"""THE OVER-EAGER FIX IS THE REAL RISK. Weighting a path like a name would let `search("src")`
promote every symbol under `src/` above the one actually called `src`, which is a worse surface
than the one this replaces. `loader_unrelated` is NAMED for the query; `_candidate_paths` only
lives in a file named for it, so the named one must come first.
@brief Name beats path.
@return None.
@version 1
"""
names = [row.name for row in search(loader_db, "loader", 25)]
assert names.index("loader_unrelated") < names.index("_candidate_paths"), (
f"a path match outranked a name match, which would bury named symbols: {names}"
)1 more lines, not shown
Activity · 2 steps
test_a_symbol_is_findable_by_the_file_it_lives_in
None test_search_matches_file_path.test_a_symbol_is_findable_by_the_file_it_lives_in(Path loader_db)
Searching the file's name must find the symbol defined in it.
tests/test_search_matches_file_path.py:103
Checks
assert "_candidate_paths" in names, (f"searching 'loader' did not surface the symbol defined in _loader.py; got {names}" )
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-INDEX-004 | measured | |
| REQ-DDB-QUERY-001 | measured | |
| REQ-DDB-QUERY-003 | measured | |
| REQ-DDB-QUERY-007 | measured | |
| REQ-DDB-QUERY-012 | measured |
Source · 15 lines
def test_a_symbol_is_findable_by_the_file_it_lives_in(loader_db: Path) -> None:
"""THE REGRESSION, NAMED. `_candidate_paths` contains neither "loader" nor "manifest" in its
name or brief; `_loader.py` is the only connection a natural query has to it.
@brief A path match surfaces the symbol.
@return None.
@version 1
"""
names = [row.name for row in search(loader_db, "loader", 25)]
assert "_candidate_paths" in names, (
f"searching 'loader' did not surface the symbol defined in _loader.py; got {names}"
)