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

Method _addexcinfo

src/_pytest/unittest.py:207–238  ·  view source on GitHub ↗
(self, rawexcinfo: "_SysExcInfoType")

Source from the content-addressed store, hash-verified

205 pass
206
207 def _addexcinfo(self, rawexcinfo: "_SysExcInfoType") -> None:
208 # Unwrap potential exception info (see twisted trial support below).
209 rawexcinfo = getattr(rawexcinfo, "_rawexcinfo", rawexcinfo)
210 try:
211 excinfo = _pytest._code.ExceptionInfo[BaseException].from_exc_info(rawexcinfo) # type: ignore[arg-type]
212 # Invoke the attributes to trigger storing the traceback
213 # trial causes some issue there.
214 excinfo.value
215 excinfo.traceback
216 except TypeError:
217 try:
218 try:
219 values = traceback.format_exception(*rawexcinfo)
220 values.insert(
221 0,
222 "NOTE: Incompatible Exception Representation, "
223 "displaying natively:\n\n",
224 )
225 fail("".join(values), pytrace=False)
226 except (fail.Exception, KeyboardInterrupt):
227 raise
228 except BaseException:
229 fail(
230 "ERROR: Unknown Incompatible Exception "
231 "representation:\n%r" % (rawexcinfo,),
232 pytrace=False,
233 )
234 except KeyboardInterrupt:
235 raise
236 except fail.Exception:
237 excinfo = _pytest._code.ExceptionInfo.from_current()
238 self.__dict__.setdefault("_excinfo", []).append(excinfo)
239
240 def addError(
241 self, testcase: "unittest.TestCase", rawexcinfo: "_SysExcInfoType"

Callers 5

addErrorMethod · 0.95
addFailureMethod · 0.95
addSkipMethod · 0.95
addExpectedFailureMethod · 0.95
addUnexpectedSuccessMethod · 0.95

Calls 6

failFunction · 0.90
from_exc_infoMethod · 0.80
insertMethod · 0.80
from_currentMethod · 0.80
appendMethod · 0.80
setdefaultMethod · 0.80

Tested by

no test coverage detected