This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author dseomn
Recipients dseomn
Date 2020-11-02.18:25:59
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1604341559.53.0.224869314437.issue42247@roundup.psfhosted.org>
In-reply-to
Content
The traceback in the output of the attached test (see below) doesn't include line 5, which is where the original exception is raised. I think this is because https://github.com/python/cpython/blob/b9ee4af4c643a323779fd7076e80b29d611f2709/Lib/unittest/result.py#L180-L186 uses the `limit` parameter to try to hide the implementation of `self.fail()` from the traceback, but `traceback.TracebackException.format()` applies the limit to the chained exception. I'm not sure if that's a bug in unittest or traceback, but from the comment in the above part of unittest, I don't think it's intentional.


F
======================================================================
FAIL: test_foo (__main__.FooTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "foo.py", line 12, in test_foo
    foo()
ValueError: foo

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "foo.py", line 14, in test_foo
    self.fail('foo() raised ValueError')
AssertionError: foo() raised ValueError

----------------------------------------------------------------------
Ran 1 test in 0.000s

FAILED (failures=1)
History
Date User Action Args
2020-11-02 18:25:59dseomnsetrecipients: + dseomn
2020-11-02 18:25:59dseomnsetmessageid: <1604341559.53.0.224869314437.issue42247@roundup.psfhosted.org>
2020-11-02 18:25:59dseomnlinkissue42247 messages
2020-11-02 18:25:59dseomncreate