-
Notifications
You must be signed in to change notification settings - Fork 3
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
Test exception handling preserves the call stack. #17
base: main
Are you sure you want to change the base?
Conversation
dfba7db
to
701383f
Compare
This way, using a once decorator will not swallow all exception traces.
701383f
to
0c79890
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like no code changes were needed, this just adds test coverage?
container.exception = exception | ||
traceback_exception = traceback.TracebackException.from_exception(exception) | ||
if not len(traceback_exception.stack): | ||
test.fail("Exception stack not preserved. Did you use the raw assertRaises by mistake?") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there was a raw assertRaises, wouldn't we never get to this failure in the first place?
locations = [(frame.filename, frame.lineno) for frame in traceback_exception.stack] | ||
line_number = line.line | ||
error_message = [ | ||
f"Traceback for exception {repr(exception)} did not have frame on line {line_number}. Exception below\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is a bit strange, can you explain what it's about?
Yup, exactly! |
This way, using a once decorator will not swallow all exception traces.