[issue44280] unittest filters out too many assertion stack frames from context/cause chains

2021-06-02 Thread Irit Katriel


Irit Katriel  added the comment:

Agreed.

--
nosy: +iritkatriel
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> unittest swallows part of stack trace when raising 
AssertionError in a TestCase

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44280] unittest filters out too many assertion stack frames from context/cause chains

2021-06-01 Thread Peter Hawkins


Change by Peter Hawkins :


--
components: +Library (Lib)
type:  -> behavior

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44280] unittest filters out too many assertion stack frames from context/cause chains

2021-06-01 Thread Peter Hawkins


New submission from Peter Hawkins :

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.

--
messages: 394865
nosy: peter.hawkins
priority: normal
severity: normal
status: open
title: unittest filters out too many assertion stack frames from context/cause 
chains
versions: Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com