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

Class ExceptionChainRepr

src/_pytest/_code/code.py:1296–1320  ·  view source on GitHub ↗

A chain of exceptions, separated by descriptions (e.g. "The above exception was the direct cause of the following exception").

Source from the content-addressed store, hash-verified

1294
1295@dataclasses.dataclass(eq=False)
1296class ExceptionChainRepr(ExceptionRepr):
1297 """A chain of exceptions, separated by descriptions (e.g. "The above
1298 exception was the direct cause of the following exception")."""
1299
1300 chain: Sequence[tuple[ReprTraceback, ReprFileLocation | None, str | None]]
1301
1302 def __init__(
1303 self,
1304 chain: Sequence[tuple[ReprTraceback, ReprFileLocation | None, str | None]],
1305 ) -> None:
1306 # reprcrash and reprtraceback of the outermost (the newest) exception
1307 # in the chain.
1308 super().__init__(
1309 reprtraceback=chain[-1][0],
1310 reprcrash=chain[-1][1],
1311 )
1312 self.chain = chain
1313
1314 def toterminal(self, tw: TerminalWriter) -> None:
1315 for reprtraceback, reprcrash, description in self.chain:
1316 reprtraceback.toterminal(tw)
1317 if description is not None:
1318 tw.line("")
1319 tw.line(description, yellow=True)
1320 super().toterminal(tw)
1321
1322
1323@dataclasses.dataclass(eq=False)

Callers 2

_report_kwargs_from_jsonFunction · 0.90
repr_excinfoMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected