classification
Title: unittest's assertRaises removes locals from tracebacks
Type: Stage:
Components: Library (Lib) Versions: Python 3.9, Python 3.8, Python 3.7, Python 3.6, Python 3.5
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: blueyed
Priority: normal Keywords:

Created on 2020-02-26 22:01 by blueyed, last changed 2020-02-29 22:16 by vstinner.

Messages (2)
msg362744 - (view) Author: daniel hahler (blueyed) * Date: 2020-02-26 22:01
I was a bit surprised to find that unittest's assertRaises clears the locals on the traceback, which e.g. prevents pytest to display them in case of failures.

This was done via https://bugs.python.org/issue9815 (https://github.com/python/cpython/commit/9681022f1ee5c6c9160c515b24d2a3d1efe8b90d).

Maybe this should only get done for expected failures, so that unexpected exceptions can be inspected better?
msg362753 - (view) Author: daniel hahler (blueyed) * Date: 2020-02-26 23:25
The test for issue9815 passes since bbd3cf8f1e (bpo-23890).

It seems like `traceback.clear_frames(tb)` should probably removed altogether?
History
Date User Action Args
2020-02-29 22:16:15vstinnersetnosy: - vstinner
2020-02-26 23:25:22blueyedsetnosy: + vstinner
messages: + msg362753
2020-02-26 22:01:11blueyedcreate