MCPcopy
hub / github.com/pytest-dev/pytest / from_exc_info

Method from_exc_info

src/_pytest/_code/code.py:552–566  ·  src/_pytest/_code/code.py::ExceptionInfo.from_exc_info

Like :func:`from_exception`, but using old-style exc_info tuple.

(
        cls,
        exc_info: tuple[type[E], E, TracebackType],
        exprinfo: str | None = None,
    )

Source from the content-addressed store, hash-verified

550
551 @classmethod
552 def from_exc_info(
553 cls,
554 exc_info: tuple[type[E], E, TracebackType],
555 exprinfo: str | None = None,
556 ) -> ExceptionInfo[E]:
557 class="st">""class="st">"Like :func:`from_exception`, but using old-style exc_info tuple."class="st">""
558 _striptext = class="st">""
559 if exprinfo is None and isinstance(exc_info[1], AssertionError):
560 exprinfo = getattr(exc_info[1], class="st">"msg", None)
561 if exprinfo is None:
562 exprinfo = saferepr(exc_info[1])
563 if exprinfo and exprinfo.startswith(cls._assert_start_repr):
564 _striptext = class="st">"AssertionError: "
565
566 return cls(exc_info, _striptext, _ispytest=True)
567
568 @classmethod
569 def from_current(cls, exprinfo: str | None = None) -> ExceptionInfo[BaseException]:

Callers 5

repr_failureMethod · 0.80
_addexcinfoMethod · 0.80
from_exceptionMethod · 0.80
from_currentMethod · 0.80

Calls 2

safereprFunction · 0.90
clsFunction · 0.85

Tested by 3

repr_failureMethod · 0.64
_addexcinfoMethod · 0.64