Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unittest's assertRaises removes locals from tracebacks #83947

Open
blueyed mannequin opened this issue Feb 26, 2020 · 3 comments
Open

unittest's assertRaises removes locals from tracebacks #83947

blueyed mannequin opened this issue Feb 26, 2020 · 3 comments
Labels
3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes stdlib Python modules in the Lib dir

Comments

@blueyed
Copy link
Mannequin

blueyed mannequin commented Feb 26, 2020

BPO 39766
Nosy @blueyed, @jacksonriley

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2020-02-26.22:01:11.668>
labels = ['3.8', '3.7', 'library', '3.9']
title = "unittest's assertRaises removes locals from tracebacks"
updated_at = <Date 2021-05-11.13:38:40.113>
user = 'https://github.com/blueyed'

bugs.python.org fields:

activity = <Date 2021-05-11.13:38:40.113>
actor = 'jacksonriley'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2020-02-26.22:01:11.668>
creator = 'blueyed'
dependencies = []
files = []
hgrepos = []
issue_num = 39766
keywords = []
message_count = 3.0
messages = ['362744', '362753', '393457']
nosy_count = 2.0
nosy_names = ['blueyed', 'jacksonriley']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = None
url = 'https://bugs.python.org/issue39766'
versions = ['Python 3.5', 'Python 3.6', 'Python 3.7', 'Python 3.8', 'Python 3.9']

@blueyed
Copy link
Mannequin Author

blueyed mannequin commented Feb 26, 2020

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 (9681022).

Maybe this should only get done for expected failures, so that unexpected exceptions can be inspected better?

@blueyed blueyed mannequin added 3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes stdlib Python modules in the Lib dir labels Feb 26, 2020
@blueyed
Copy link
Mannequin Author

blueyed mannequin commented Feb 26, 2020

The test for bpo-9815 passes since bbd3cf8 (bpo-23890).

It seems like traceback.clear_frames(tb) should probably removed altogether?

@jacksonriley
Copy link
Mannequin

jacksonriley mannequin commented May 11, 2021

+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.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes stdlib Python modules in the Lib dir
Projects
Status: No status
Development

No branches or pull requests

0 participants