fix(test-guards): an expected error is an outcome check, so a refusal test is not mock-only

A refusal test raises, then checks nothing was written with
assert_not_called. The mock-only signal counted only plain asserts as outcome
checks, so 28 of the 44 tests it flagged in Grimoire's own suite were refusals.
pytest.raises and assertRaises now count.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-01 07:10:02 -05:00
co-authored by Claude Opus 5.5
parent 2a4d73176e
commit 881e0fd75f
2 changed files with 10 additions and 1 deletions
+7 -1
View File
@@ -75,7 +75,13 @@ SIGNALS = {
_MOCK_ASSERT_RE = re.compile(
r"\.assert_(?:called|awaited|not_called|not_awaited|any_call|has_calls)\w*\(|toHaveBeenCalled"
)
_PLAIN_ASSERT_RE = re.compile(r"^\s*assert\b|\bexpect\((?![^\n]*toHaveBeenCalled)", re.MULTILINE)
# An outcome check: a plain assert, an expect that is not about a mock, or an
# expected error. A refusal test that raises and then checks nothing was
# written has checked its outcome; the mock assertion is the "nothing" half.
_PLAIN_ASSERT_RE = re.compile(
r"^\s*assert\b|\bexpect\((?![^\n]*toHaveBeenCalled)|\bpytest\.raises\(|\.assertRaises\w*\(",
re.MULTILINE,
)
def is_test_path(path: str) -> bool: