test(inbox): bind side-effecting pop() before assert

CodeQL flagged the bare `assert state.pop(...) is None` — under
`python -O` asserts are stripped, which would skip the call entirely
and the test would silently pass without exercising the code. Bind
the result first so the call always runs.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Hongming Wang 2026-04-30 16:39:45 -07:00
parent b47d4ceb00
commit d061642cfc

View File

@ -182,7 +182,10 @@ def test_pop_removes_specific_message(state: inbox.InboxState):
def test_pop_missing_id_returns_none(state: inbox.InboxState):
state.record(_msg("a"))
assert state.pop("does-not-exist") is None
# Bind the result before asserting so the call still runs under
# ``python -O`` (which strips bare assert statements).
result = state.pop("does-not-exist")
assert result is None
# Original message still present
assert len(state.peek(10)) == 1