test_the_used_path_precedes_the_parse

Tests › tests/test_hook.py

passed Passed in the packaged run.

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

  1. tree = ast.parse(HOOK_SOURCE.read_text(encoding="utf-8"))
  2. main = next( node for node in ast.walk(tree) if isinstance(node, ast.FunctionDef) and node.name == "main" )
2 more
  1. used_line = next( node.lineno for node in ast.walk(main) if isinstance(node, ast.Name) and node.id == "USED_FLAG" )
  2. 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

  1. —
→

Then

  1. ✓ parse_lines holds
  2. ✓ used_line is less than min(parse_lines)

tests/test_hook.py:329 · its file's page

What it checks (2)

  1. assert parse_lines, "main no longer calls _target_name — this test would be vacuous" not attributed
  2. assert 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)

requirementlinked byimplementers exercised
REQ-DDB-WIKI-054catalogunknown