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

Method test_raises_repr_inflight

testing/python/raises.py:37–52  ·  view source on GitHub ↗

Ensure repr() on an exception info inside a pytest.raises with block works (#4386)

(self)

Source from the content-addressed store, hash-verified

35 raise AssertionError("ohai")
36
37 def test_raises_repr_inflight(self):
38 """Ensure repr() on an exception info inside a pytest.raises with block works (#4386)"""
39
40 class E(Exception):
41 pass
42
43 with pytest.raises(E) as excinfo:
44 # this test prints the inflight uninitialized object
45 # using repr and str as well as pprint to demonstrate
46 # it works
47 print(str(excinfo))
48 print(repr(excinfo))
49 import pprint
50
51 pprint.pprint(excinfo)
52 raise E()
53
54 def test_raises_as_contextmanager(self, pytester: Pytester) -> None:
55 pytester.makepyfile(

Callers

nothing calls this directly

Calls 1

EClass · 0.85

Tested by

no test coverage detected