test_the_hook_imports_nothing_from_the_clew_package¶
Tests › tests/test_hook.py
What this test is for
Why it exists
THE PROPERTY THE MODULE DOCSTRING ALREADY CLAIMED WAS GATED, AND WHICH NOTHING GATED. It says "it imports nothing from `clew` and must keep importing nothing: the gate asserts it" — no such gate existed until this test. In a file whose own argument is that a component lying about itself teaches a reader to discount everything else it says, that is worth more than the check.
Verifies REQ-DDB-WIKI-054
Given
tree = ast.parse(HOOK_SOURCE.read_text(encoding="utf-8"))imported: set[str] = set()
4 more
for node in ast.walk(tree): if isinstance(node, ast.Import): imported.update(alias.name for alias in node.names) elif isinstance(node, ast.ImportFrom) and node.module: imported.add(node.module)offenders = {m for m in imported if m == "clew" or m.startswith("clew.")}probe = ( "import sys; import clew_hook; " "bad=[m for m in sys.modules if m=='clew' or m.startswith('clew.')]; " "print(','.join(sorted(bad)))" )result = subprocess.run( [sys.executable, "-c", probe], capture_output=True, text=True, cwd=str(REPO), check=False, )
When
- —
Then
- ✓ offenders is false
- ✓ result.returncode equals 0
- ✓ result.stdout.strip() is false
tests/test_hook.py:1004 · its file's page
What it checks (3)
assert not offenders, f"the hook imports from the clew package: {sorted(offenders)}"not attributedassert result.returncode == 0, f"the probe failed: {result.stderr[:300]}"not attributedassert not result.stdout.strip(), ( f"importing clew_hook pulled in clew modules: {result.stdout.strip()} — this is the " f"157 ms the module docstring says was removed by moving out of the package" )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 |