test_the_used_path_precedes_the_parse¶
Tests › tests/test_hook.py
What this test is for
Why it exists
THE MOST FREQUENT CASE IN A HEALTHY SESSION MUST HAVE THE NARROWEST SURFACE. When the tool that just ran was a clew tool the hook needs nothing from the event at all, so that branch returns before any parsing happens. Asserted over statement ORDER in `main`, because "it happens to be earlier in the file" is exactly the kind of property a refactor silently inverts.
Verifies REQ-DDB-WIKI-054
Given
tree = ast.parse(HOOK_SOURCE.read_text(encoding="utf-8"))main = next( node for node in ast.walk(tree) if isinstance(node, ast.FunctionDef) and node.name == "main" )
2 more
used_line = next( node.lineno for node in ast.walk(main) if isinstance(node, ast.Name) and node.id == "USED_FLAG" )parse_lines = [ node.lineno for node in ast.walk(main) if isinstance(node, ast.Call) and isinstance(node.func, ast.Name) and node.func.id == "_target_name" ]
When
- —
Then
- ✓ parse_lines holds
- ✓ used_line is less than min(parse_lines)
tests/test_hook.py:329 · its file's page
What it checks (2)
assert parse_lines, "main no longer calls _target_name — this test would be vacuous"not attributedassert used_line < min(parse_lines), ( "the --used branch must return before the event is parsed, so a session already using " "the index never has its event examined" )not attributed
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.
Requirements it verifies (1)
| requirement | linked by | implementers exercised |
|---|---|---|
| REQ-DDB-WIKI-054 | catalog | unknown |