Skip to content

Commit 8f6db5a

Browse files
gomri15nicoddemus
andauthored
Update src/_pytest/runner.py
Co-authored-by: Bruno Oliveira <[email protected]>
1 parent c2e1837 commit 8f6db5a

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/_pytest/runner.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -351,15 +351,15 @@ def from_call(
351351
(reraise,) if not isinstance(reraise, tuple) else reraise
352352
)
353353

354-
# EG-aware path (only direct children; no nesting)
354+
# ExceptionGroup-aware path: check if any of the direct children
355+
# is an instance of the `reraise` parameter, and reraise the exception
356+
# accordingly (#13650).
355357
if isinstance(val, BaseExceptionGroup):
356-
exception_group = cast(BaseExceptionGroup, val)
357-
for child in exception_group.exceptions:
358+
for child in val.exceptions:
358359
if isinstance(child, reraise_types):
359-
# B904: chain to the original exception we caught
360360
raise child from caught
361-
362-
if isinstance(val, reraise_types): # non-group or no match
361+
# Not an exception group, check if we need to reraise it.
362+
elif isinstance(val, reraise_types):
363363
raise
364364

365365
result = None

0 commit comments

Comments
 (0)