diff options
author | Nikolay Kondratyev <kondratyev.nv@gmail.com> | 2019-04-19 18:54:21 +0300 |
---|---|---|
committer | Nikolay Kondratyev <kondratyev.nv@gmail.com> | 2019-04-19 18:54:21 +0300 |
commit | bc00d0f7db842780c899613108bd6c1e252d12a8 (patch) | |
tree | 7b31d39df6d031b7efca3c9abb26445cef42ad2c /testing/test_session.py | |
parent | e87d3d70e2da2663ee619ec60e878be928d49506 (diff) | |
download | pytest-bc00d0f7db842780c899613108bd6c1e252d12a8.tar.gz |
Fix handle repr error with showlocals and verbose output
Diffstat (limited to 'testing/test_session.py')
-rw-r--r-- | testing/test_session.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/testing/test_session.py b/testing/test_session.py index 4cd564a89..377b28937 100644 --- a/testing/test_session.py +++ b/testing/test_session.py @@ -134,6 +134,30 @@ class SessionTests(object): != -1 ) + def test_broken_repr_with_showlocals_verbose(self, testdir): + p = testdir.makepyfile( + """ + class ObjWithErrorInRepr: + def __repr__(self): + raise NotImplementedError + + def test_repr_error(): + x = ObjWithErrorInRepr() + assert x == "value" + """ + ) + reprec = testdir.inline_run("--showlocals", "-vv", p) + passed, skipped, failed = reprec.listoutcomes() + assert (len(passed), len(skipped), len(failed)) == (0, 0, 1) + entries = failed[0].longrepr.reprtraceback.reprentries + assert len(entries) == 1 + repr_locals = entries[0].reprlocals + assert repr_locals.lines + assert len(repr_locals.lines) == 1 + assert repr_locals.lines[0].startswith( + 'x = <[NotImplementedError("") raised in repr()] ObjWithErrorInRepr' + ) + def test_skip_file_by_conftest(self, testdir): testdir.makepyfile( conftest=""" |