From 352db284289daa98eabc4a884c51141ee02cd6be Mon Sep 17 00:00:00 2001 From: Cheukting Date: Thu, 23 Jun 2022 11:33:10 +0800 Subject: [PATCH] fall back to native when handeling to exception groups --- src/_pytest/_code/code.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/_pytest/_code/code.py b/src/_pytest/_code/code.py index 304a5cbd7..5dd309c2b 100644 --- a/src/_pytest/_code/code.py +++ b/src/_pytest/_code/code.py @@ -923,7 +923,12 @@ class FormattedExcinfo: seen: Set[int] = set() while e is not None and id(e) not in seen: seen.add(id(e)) - if excinfo_: + if isinstance(e, ExceptionGroup): + reprtraceback = ReprTracebackNative( + traceback.format_exception(type(e), e, excinfo.traceback[0]._rawentry) + ) + reprcrash = None + elif excinfo_: reprtraceback = self.repr_traceback(excinfo_) reprcrash: Optional[ReprFileLocation] = ( excinfo_._getreprcrash() if self.style != "value" else None