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
Include location footer in logs for AssertionErrors #128
Include location footer in logs for AssertionErrors #128
Conversation
The location (file + lnum) of the test failure is very useful, since it allows to quickly go there in an editor. |
Very good point @blueyed. There's two relevant lines: the location of the failing test definition, and the location the failure/error actually occurs. I wonder what the least confusing way to communicate those to the user is? Any thoughts @jayeshathila? I'd be open to changing the existing output if we can think of something clearer. |
With pytest I am using |
Ya, I am myself aligned with that we should print the line_num where failure actually occur. Will see what can be done to print the line_num. Will update my finding here. |
dfef175
to
a58489a
Compare
@darrenburns @blueyed I have added line_number explicitly (using |
ward/testing.py
Outdated
@@ -217,6 +219,12 @@ def get_result(self, outcome, exception=None): | |||
if outcome in (TestOutcome.PASS, TestOutcome.SKIP): | |||
result = TestResult(self, outcome) | |||
else: | |||
if isinstance(exception, AssertionError): | |||
exc_traceback = sys.exc_info()[-1] |
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.
My understanding is that sys.exc_info
only works in the context of except
blocks?
I think you can get the traceback from the exception using exc_traceback = exception.__traceback__
.
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.
My understanding is that
sys.exc_info
only works in the context ofexcept
blocks?I think you can get the traceback from the exception using
exc_traceback = exception.__traceback__
.
Ah. Agree get_result being public method I shouldn't expect it to be in context of except
. Will change this to use exception.__traceback
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.
@darrenburns, Updated with exception.__traceback__
.
a58489a
to
6c4fa42
Compare
Looks good, thanks @jayeshathila. Will take a closer look asap! |
This change has been included in Ward 0.39.0b0 - thanks again @jayeshathila :) |
Changes:
Concerns:
issue #126