MCPcopy Create free account
hub / github.com/pytest-dev/pytest / from_exc_info

Method from_exc_info

src/_pytest/_code/code.py:469–493  ·  view source on GitHub ↗

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,
    )

Source from the content-addressed store, hash-verified

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(

Callers 8

repr_failureMethod · 0.80
_repr_failure_pyMethod · 0.80
raisesFunction · 0.80
_addexcinfoMethod · 0.80
from_currentMethod · 0.80
repr_excinfoMethod · 0.80
mainFunction · 0.80

Calls 2

safereprFunction · 0.90
clsFunction · 0.85

Tested by 3

repr_failureMethod · 0.64
_addexcinfoMethod · 0.64