Files
troupe-standup/wizard-work/beam/test_tarjan_articulation.py
T
volt 1bd59257fe volt: Q160 -- beam test bound its module to a host path; binds beside itself and asserts it
bb8aec7 landed wizard-work/beam/test_tarjan_articulation.py with
sys.path.insert(0, '/root/.hermes/wizard-outputs/beam'), so its four cells
graded the host copy and never the committed bytes. Repo gate at that commit:
import-resolve FAULT, 1 OUTSIDE_REPO finding. Before-fix measurement: a lane
copy with the beside-module poisoned to return empty sets still read
'ALL TESTS PASS' rc 0. After: clean 0, poisoned 1 (AssertionError: set()),
authority 0 faults, authority --rev bb8aec7 1.

Ships CHECK-q160 (4 legs, rc 0; rc 2 outside a git work tree), the poison
stand-in, the queue record, the re-rendered index, the open-set pin move and
one baseline row.
2026-11-03 05:44:45 +00:00

46 lines
1.9 KiB
Python

"""Tests for tarjan_articulation.articulation_points / bridges.
Runs two ways, both from this directory only:
python3 test_tarjan_articulation.py
python3 -m unittest discover -p 'test_*.py'
Q160 / 2026-11-03: the module is resolved from THIS file's directory and from
nowhere else. The file landed with
sys.path.insert(0, '/root/.hermes/wizard-outputs/beam')
which put a HOST directory first on sys.path, so all four cells below graded
/root/.hermes/wizard-outputs/beam/tarjan_articulation.py and not the committed
bytes. Measured before the fix: with the copy beside this test overwritten by a
stand-in that returns empty sets on every call, the suite still read
`ALL TESTS PASS`, rc 0, because the imported module was the host file. The
assertion below is what makes the binding a fact rather than an intention (the
rule test_toposort.py states at Q61 and test_lfu_cache.py at Q98).
"""
import pathlib
import sys
HERE = pathlib.Path(__file__).resolve().parent
sys.path.insert(0, str(HERE))
import tarjan_articulation as module_under_test
from tarjan_articulation import articulation_points, bridges
# The module under test must be the committed file next to this test.
MODULE_PATH = pathlib.Path(module_under_test.__file__).resolve()
assert MODULE_PATH == (HERE / "tarjan_articulation.py"), (MODULE_PATH, HERE)
adj = {'1': ['2'], '2': ['1', '3'], '3': ['2', '4'], '4': ['3']}
assert sorted(articulation_points(adj)) == ['2', '3'], articulation_points(adj)
assert sorted(bridges(adj)) == [('1', '2'), ('2', '3'), ('3', '4')], bridges(adj)
adj = {'a': ['b', 'c'], 'b': ['a', 'c'], 'c': ['a', 'b']}
assert articulation_points(adj) == set(), articulation_points(adj)
assert bridges(adj) == set(), bridges(adj)
adj = {'1': ['2', '2'], '2': ['1', '1']}
assert bridges(adj) == set(), bridges(adj)
adj = {'c': ['a', 'b', 'd'], 'a': ['c'], 'b': ['c'], 'd': ['c']}
assert articulation_points(adj) == {'c'}, articulation_points(adj)
print("ALL TESTS PASS")