Return an ExceptionInfo for an existing exc_info tuple. .. warning:: Experimental API :param exprinfo: A text string helping to determine if we should strip ``AssertionError`` from the output. Defaults to the exception message/``__st
(
cls,
exc_info: Tuple[Type[E], E, TracebackType],
exprinfo: Optional[str] = None,
)
| 467 | |
| 468 | @classmethod |
| 469 | def from_exc_info( |
| 470 | cls, |
| 471 | exc_info: Tuple[Type[E], E, TracebackType], |
| 472 | exprinfo: Optional[str] = None, |
| 473 | ) -> "ExceptionInfo[E]": |
| 474 | """Return an ExceptionInfo for an existing exc_info tuple. |
| 475 | |
| 476 | .. warning:: |
| 477 | |
| 478 | Experimental API |
| 479 | |
| 480 | :param exprinfo: |
| 481 | A text string helping to determine if we should strip |
| 482 | ``AssertionError`` from the output. Defaults to the exception |
| 483 | message/``__str__()``. |
| 484 | """ |
| 485 | _striptext = "" |
| 486 | if exprinfo is None and isinstance(exc_info[1], AssertionError): |
| 487 | exprinfo = getattr(exc_info[1], "msg", None) |
| 488 | if exprinfo is None: |
| 489 | exprinfo = saferepr(exc_info[1]) |
| 490 | if exprinfo and exprinfo.startswith(cls._assert_start_repr): |
| 491 | _striptext = "AssertionError: " |
| 492 | |
| 493 | return cls(exc_info, _striptext, _ispytest=True) |
| 494 | |
| 495 | @classmethod |
| 496 | def from_current( |