You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
pytest.RaisesGroup calls the check function with simple exceptions instead of the group #14324
errors with AttributeError: 'ValueError' object has no attribute 'exceptions' because the check function gets invoked twice, the first time with the exception group for actually performing the check, and the second time with the ValueError raised by the foo function.
As a further proof, the stdout of the run is:
<class 'ExceptionGroup'>
<class 'ValueError'>
This seems wrong, as the docs of RaisesGroup says
check (Callable[[E], bool]) – If specified, a callable that will be called with the group as a parameter after successfully matching the expected exceptions. If it returns True it will be considered a match, if not it will be considered a failed match.
I'm on python 3.12, with just pytest==9.0.2 installed in the environment, but I can reproduce the same issue on 3.14.
Ah, definitely an oversight. We only call check for the contained exception in order to be able to give a more helpful error message if it fails on the group - but I had not considered that it may crash if we try to do that. Good catch!
Activity
bluetech commentedon May 3, 2026
This does seem like a bug.
@jakkdl do you mind confirming that the intent is for
checkto only be called on the exception group, and not the exceptions?jakkdl commentedon May 11, 2026
Ah, definitely an oversight. We only call
checkfor the contained exception in order to be able to give a more helpful error message if it fails on the group - but I had not considered that it may crash if we try to do that. Good catch!