diff options
author | Daniel Hahler <git@thequod.de> | 2019-10-09 05:16:27 +0200 |
---|---|---|
committer | Daniel Hahler <git@thequod.de> | 2019-10-09 19:27:46 +0200 |
commit | 2a2fe7d3db12b03b9a62392bccaceacd256c063e (patch) | |
tree | c1387d0c7d1f42473aa457bda75b29bcfd4a9e92 /testing/code | |
parent | 5c92a0f695c4f302612c50249f0a7bff1047f6b2 (diff) | |
download | pytest-2a2fe7d3db12b03b9a62392bccaceacd256c063e.tar.gz |
Improve ExceptionInfo.__repr__
Diffstat (limited to 'testing/code')
-rw-r--r-- | testing/code/test_excinfo.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/testing/code/test_excinfo.py b/testing/code/test_excinfo.py index e2f06a0a2..3f205b131 100644 --- a/testing/code/test_excinfo.py +++ b/testing/code/test_excinfo.py @@ -316,8 +316,19 @@ def test_excinfo_exconly(): def test_excinfo_repr_str(): excinfo = pytest.raises(ValueError, h) - assert repr(excinfo) == "<ExceptionInfo ValueError tblen=4>" - assert str(excinfo) == "<ExceptionInfo ValueError tblen=4>" + assert repr(excinfo) == "<ExceptionInfo ValueError() tblen=4>" + assert str(excinfo) == "<ExceptionInfo ValueError() tblen=4>" + + class CustomException(Exception): + def __repr__(self): + return "custom_repr" + + def raises(): + raise CustomException() + + excinfo = pytest.raises(CustomException, raises) + assert repr(excinfo) == "<ExceptionInfo custom_repr tblen=2>" + assert str(excinfo) == "<ExceptionInfo custom_repr tblen=2>" def test_excinfo_for_later(): |