fix #4386 - handle uninitialized exceptioninfo in repr/str

This commit is contained in:
Ronny Pfannschmidt
2018-11-22 20:43:58 +01:00
parent 3eaa6d8835
commit b71bd9b300
3 changed files with 24 additions and 4 deletions

View File

@@ -33,6 +33,18 @@ class TestRaises(object):
except pytest.raises.Exception:
pass
def test_raises_repr_inflight(self):
with pytest.raises(RuntimeError) as excinfo:
# this test prints the inflight uninitialized object
# using repr and str as well as pprint to demonstrate
# it works
print(str(excinfo))
print(repr(excinfo))
import pprint
pprint.pprint(excinfo)
raise RuntimeError(1)
def test_raises_as_contextmanager(self, testdir):
testdir.makepyfile(
"""