-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Fix ANSI escape codes for colored output not handled correctly with pytest.fail(..., pytrace=False) #12959
base: main
Are you sure you want to change the base?
Fix ANSI escape codes for colored output not handled correctly with pytest.fail(..., pytrace=False) #12959
Changes from 7 commits
f0d86b8
25848f4
c6a5c8d
d50ad93
7a2cf77
0e56876
26eb974
2122580
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ANSI escape codes for colored output now handled correctly in :func:`pytest.fail` with `pytrace=False`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -119,8 +119,8 @@ | |
return text | ||
|
||
def get_write_msg(self, idx): | ||
flag, msg = self.lines[idx] | ||
assert flag == TWMock.WRITE | ||
assert self.lines[idx][0] == TWMock.WRITE | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added this so that calling I can revert it back if needed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's fine, thanks! |
||
msg = self.lines[idx][1] | ||
return msg | ||
|
||
fullwidth = 80 | ||
|
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.
Using
TerminalWriter.write
instead ofTerminalWriter.line
because when usingTWMock
. we can't distinguish lines written withTWMock._write_source
and lines written withline
directly, whereas withTWMock.write
we can, with the flag.We could add a flag for
TWMock._write_source
as well, like so:But then we'll have to change around half the test cases in
test_excinfo.py
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.
Thanks for the explanation! I guess this rationale would be nice to have as a comment in the code itself, to help future readers.
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.
sure