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

Function test_excinfo_repr_str

testing/code/test_excinfo.py:354–370  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

352
353
354def test_excinfo_repr_str() -> None:
355 with pytest.raises(ValueError) as excinfo1:
356 h()
357 assert repr(excinfo1) == "<ExceptionInfo ValueError() tblen=4>"
358 assert str(excinfo1) == "<ExceptionInfo ValueError() tblen=4>"
359
360 class CustomException(Exception):
361 def __repr__(self):
362 return "custom_repr"
363
364 def raises() -> None:
365 raise CustomException()
366
367 with pytest.raises(CustomException) as excinfo2:
368 raises()
369 assert repr(excinfo2) == "<ExceptionInfo custom_repr tblen=2>"
370 assert str(excinfo2) == "<ExceptionInfo custom_repr tblen=2>"
371
372
373def test_excinfo_for_later() -> None:

Callers

nothing calls this directly

Calls 2

hFunction · 0.70
raisesFunction · 0.70

Tested by

no test coverage detected