Skip to content

Do not retry RaisesGroup check on contained exceptions - #15276

Open
theman6660 wants to merge 1 commit into
pytest-dev:mainfrom
theman6660:fix/14324-group-check
Open

theman6660 wants to merge 1 commit into
pytest-dev:mainfrom
theman6660:fix/14324-group-check

Conversation

@theman6660

Copy link
Copy Markdown

When a RaisesGroup check returns False, failure-message construction currently retries the callback on a contained exception. A callback expecting an exception group can then raise AttributeError, and callbacks with side effects can run twice.

Remove that diagnostic probe so the check is called only on the matched group. The failed-check message is retained; the suggestion inferred by calling the callback on the wrong type is removed.

Regression tests cover ExceptionGroup and BaseExceptionGroup, True/False check results, a single callback invocation, and propagation of exceptions raised by the callback itself. The new failing-check cases reproduce the bug against the original source. Validation: 71 raises/raises_group tests passed, and changed-file pre-commit checks including mypy passed.

Fixes #14324.

AI assistance: The implementation, tests, and this description were prepared using OpenAI Codex at my request.

Co-authored-by: Codex <noreply@openai.com>
@pyba-chronographer pyba-chronographer Bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Oct 28, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided (automation) changelog entry is part of PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pytest.RaisesGroup calls the check function with simple exceptions instead of the group

1 participant