Skip to content

Commit bc693e8

Browse files
committed
test: re-align @sensitive test with fail-CLOSED contract after master merge
The auto-merge of master into this branch (commit 7875210) resolved tests/test_protect_branches.py by taking master's side of the conflict, leaving the old test_sensitive_runtime_init_failure_is_silent in place. That test asserts @sensitive does NOT raise — but the production change in commit 58263a1 (this branch) makes @sensitive raise RuntimeError (fail-CLOSED, ADR-008). Result: CI ran the old assertion against the new production code and failed. Restore the renamed and re-asserted version of the test from commit 58263a1 — test_sensitive_runtime_init_failure_raises — so the test asserts the new contract: RuntimeError is raised and __cause__ chains the original exception. runtime.py was resolved correctly by the auto-merge (both sides kept: the new track_coverage / start_coverage_reporter / stop_coverage_reporter / _coverage_reporter_loop methods AND the existing bump_coverage_counter are all present), so no changes there.
1 parent 7875210 commit bc693e8

1 file changed

Lines changed: 21 additions & 8 deletions

File tree

tests/test_protect_branches.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -472,17 +472,30 @@ def my_charge(amount):
472472
assert "my_charge" in rt.get_sensitive_tools()
473473

474474

475-
def test_sensitive_runtime_init_failure_is_silent(test_runtime, monkeypatch):
476-
"""If runtime construction fails inside @sensitive, import must not crash."""
475+
def test_sensitive_runtime_init_failure_raises(test_runtime, monkeypatch):
476+
"""If runtime construction fails inside @sensitive, the decorator
477+
MUST raise ``RuntimeError`` (fail-CLOSED, ADR-008). The original
478+
exception is chained via ``__cause__`` so callers can still inspect
479+
the root cause.
480+
"""
477481
from nullrun import decorators
478482

479-
monkeypatch.setattr(decorators, "_get_or_create_runtime", MagicMock(side_effect=RuntimeError("x")))
480-
# Decorator must NOT raise even though registration failed.
481-
@sensitive
482-
def f():
483-
return 1
483+
original_exc = RuntimeError("x")
484+
monkeypatch.setattr(
485+
decorators,
486+
"_get_or_create_runtime",
487+
MagicMock(side_effect=original_exc),
488+
)
489+
490+
with pytest.raises(
491+
RuntimeError,
492+
match=r"@sensitive registration failed for 'f'",
493+
) as excinfo:
494+
@sensitive
495+
def f():
496+
return 1
484497

485-
assert f() == 1
498+
assert excinfo.value.__cause__ is original_exc
486499

487500

488501
# ─── reset() ──────────────────────────────────────────────────────────

0 commit comments

Comments
 (0)