Ensure repr() on an exception info inside a pytest.raises with block works (#4386)
(self)
| 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( |