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.

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, jacksonriley
Priority: normal Keywords:

Created on 2020-02-26 22:01 by blueyed, last changed 2022-04-11 14:59 by admin.

Messages (3)
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?
msg393457 - (view) Author: Jackson Riley (jacksonriley) * Date: 2021-05-11 13:38
+1 - I was surprised not to be able to get locals from many of the frames in pdb upon an unexpected exception being raised inside an assertRaises. Thanks for raising this issue Daniel.
History
Date User Action Args
2022-04-11 14:59:27adminsetgithub: 83947
2021-05-11 13:38:40jacksonrileysetnosy: + jacksonriley
messages: + msg393457
2020-02-29 22:16:15vstinnersetnosy: - vstinner
2020-02-26 23:25:22blueyedsetnosy: + vstinner
messages: + msg362753
2020-02-26 22:01:11blueyedcreate