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

Function serialize_exception_longrepr

src/_pytest/reports.py:573–594  ·  view source on GitHub ↗
(rep: BaseReport)

Source from the content-addressed store, hash-verified

571 return None
572
573 def serialize_exception_longrepr(rep: BaseReport) -> dict[str, Any]:
574 assert rep.longrepr is not None
575 # TODO: Investigate whether the duck typing is really necessary here.
576 longrepr = cast(ExceptionRepr, rep.longrepr)
577 result: dict[str, Any] = {
578 "reprcrash": serialize_repr_crash(longrepr.reprcrash),
579 "reprtraceback": serialize_repr_traceback(longrepr.reprtraceback),
580 "sections": longrepr.sections,
581 }
582 if isinstance(longrepr, ExceptionChainRepr):
583 result["chain"] = []
584 for repr_traceback, repr_crash, description in longrepr.chain:
585 result["chain"].append(
586 (
587 serialize_repr_traceback(repr_traceback),
588 serialize_repr_crash(repr_crash),
589 description,
590 )
591 )
592 else:
593 result["chain"] = None
594 return result
595
596 d = report.__dict__.copy()
597 if hasattr(report.longrepr, "toterminal"):

Callers 1

_report_to_jsonFunction · 0.85

Calls 3

serialize_repr_crashFunction · 0.85
serialize_repr_tracebackFunction · 0.85
appendMethod · 0.80

Tested by

no test coverage detected