Skip to content

Fix RaisesGroup calling check() on contained exceptions instead of Ex…#14358

Closed
kelliott1 wants to merge 4 commits intopytest-dev:mainfrom
evanwilson2123:kim-14324-raisesgroup
Closed

Fix RaisesGroup calling check() on contained exceptions instead of Ex…#14358
kelliott1 wants to merge 4 commits intopytest-dev:mainfrom
evanwilson2123:kim-14324-raisesgroup

Conversation

@kelliott1
Copy link
Copy Markdown

Fix RaisesGroup incorrectly calling check() on contained exceptions.

Files changed:
raises.py
raises_group.py (tests)

Problem:
RaisesGroup(..., check=...) invoked the check callback twice:
- once with the ExceptionGroup (correct)
- once with a contained exception (incorrect)

This could cause unexpected errors (e.g. AttributeError) and violated the documented behavior.

Fix:
Removed the extra invocation of check() on contained exceptions.
Ensured check() is only called with the ExceptionGroup.
Adjusted suggestion logic to avoid reusing the callback.

Tests:
Updated test_check() expectations.
Added regression test to ensure check() is called once and only with the group.

Result:
check() now behaves as documented and no longer receives contained exceptions.

@kelliott1 kelliott1 marked this pull request as draft April 6, 2026 19:29
@psf-chronographer psf-chronographer bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Apr 6, 2026
@kelliott1 kelliott1 closed this Apr 6, 2026
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.

1 participant