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

Method check_longrepr

testing/test_reports.py:311–331  ·  view source on GitHub ↗

Check the attributes of the given longrepr object according to the test file. We can get away with testing both CollectReport and TestReport with this function because the longrepr objects are very similar.

(longrepr: ExceptionChainRepr)

Source from the content-addressed store, hash-verified

309 report = reports[1]
310
311 def check_longrepr(longrepr: ExceptionChainRepr) -> None:
312 """Check the attributes of the given longrepr object according to the test file.
313
314 We can get away with testing both CollectReport and TestReport with this function because
315 the longrepr objects are very similar.
316 """
317 assert isinstance(longrepr, ExceptionChainRepr)
318 assert longrepr.sections == [("title", "contents", "=")]
319 assert len(longrepr.chain) == 2
320 entry1, entry2 = longrepr.chain
321 tb1, fileloc1, desc1 = entry1
322 tb2, fileloc2, desc2 = entry2
323
324 assert "ValueError('value error')" in str(tb1)
325 assert "RuntimeError('runtime error')" in str(tb2)
326
327 assert (
328 desc1
329 == "The above exception was the direct cause of the following exception:"
330 )
331 assert desc2 is None
332
333 assert report.failed
334 assert len(report.sections) == 0

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected