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 peter.hawkins
Recipients peter.hawkins
Date 2021-06-01.19:42:47
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1622576568.02.0.771904699767.issue44280@roundup.psfhosted.org>
In-reply-to
Content
Example repro:
```
import unittest


def d():
  assert 2 == 3

def c():
  d()

def b():
  c()

def a():
  try:
    b()
  except Exception as e:
    assert 1 == 2


class MyTest(unittest.TestCase):

  def testException(self):
    a()


if __name__ == '__main__':
  unittest.main()
```

Example output from Python 3.9.0:
```
$ python atest.py
F
======================================================================
FAIL: testException (__main__.MyTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/private/tmp/atest.py", line 15, in a
    b()
  File "/private/tmp/atest.py", line 11, in b
    c()
AssertionError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/private/tmp/atest.py", line 23, in testException
    a()
  File "/private/tmp/atest.py", line 17, in a
    assert 1 == 2
AssertionError

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

FAILED (failures=1)
```

Too many frames have been filtered out of the `__context__` exception, including a number of relevant frames for `c` and `d`. I believe this happens because unittest sets a `limit` here based on the contents of the main traceback:
https://github.com/python/cpython/blob/39dd141a4ba68bbb38fd00a65cdcff711acdafb5/Lib/unittest/result.py#L182

but that limit applies recursively to the `__context__` and `__cause__` chains, when the intent of the limit was presumably only to filter the main exception.
History
Date User Action Args
2021-06-01 19:42:48peter.hawkinssetrecipients: + peter.hawkins
2021-06-01 19:42:48peter.hawkinssetmessageid: <1622576568.02.0.771904699767.issue44280@roundup.psfhosted.org>
2021-06-01 19:42:48peter.hawkinslinkissue44280 messages
2021-06-01 19:42:47peter.hawkinscreate