Q105 pointed beam/CHECK at pytest; pytest is not installed on this interpreter, so the gate exited 2 and ran zero cells. run_lane_tests.py collects TestCase classes (TestLoader) and bare module-level def test_*() (FunctionTestCase) itself, treats an unimportable module and a printed FAIL transcript as faults, and exits 0/1/2. Four test files that imported pytest now use beam_assert.raises/fail and unittest.mock; no cell dropped. Measured: unittest discover 353 tests; runner 570 (353 + 217 bare); bash wizard-work/beam/CHECK rc 0; test_run_lane_tests.py 10 cells OK; 7-mutant battery in scratch copies all as expected (HEAD CHECK rc 2, broken bare rc 1, pytest import rc 1, failing TestCase rc 1, script FAIL rc 1, empty lane rc 2, control rc 0). Record: WORK-QUEUE.md Q128; report wizard-outputs/volt/2026-10-30-q128.md
36 lines
1.3 KiB
Python
36 lines
1.3 KiB
Python
"""Stdlib assertion helpers for the beam lane's bare-style test files.
|
|
|
|
Why this file exists (Q128, 2026-10-30): four of this lane's test files
|
|
imported `pytest` only for `pytest.raises` and one `pytest.fail`. On an
|
|
interpreter without pytest those four modules fail at import, so the lane's
|
|
own gate could not grade them at all -- `beam/CHECK` exited 2 with
|
|
"pytest not importable -- cannot grade" and ran zero of the lane's cells.
|
|
The surface actually used is two names, so it lives here on the standard
|
|
library instead of behind a third-party package.
|
|
|
|
`raises` is a context manager that fails unless the expected exception is
|
|
raised, matching `pytest.raises(X)` for the way these files use it (no
|
|
`match=`, no `as`). `fail` raises AssertionError with the message, matching
|
|
`pytest.fail`. Both work under `unittest`, under `pytest`, and as bare
|
|
`assert`-style modules run by `run_lane_tests.py`.
|
|
"""
|
|
|
|
import contextlib
|
|
|
|
|
|
@contextlib.contextmanager
|
|
def raises(exc_type):
|
|
"""Fail unless the block raises ``exc_type`` (or a subclass)."""
|
|
try:
|
|
yield
|
|
except exc_type:
|
|
return
|
|
raise AssertionError(
|
|
"expected %s to be raised; nothing was raised" % (exc_type.__name__,)
|
|
)
|
|
|
|
|
|
def fail(msg=""):
|
|
"""Fail the current test with ``msg``."""
|
|
raise AssertionError(msg)
|