-
-
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
ANSI escape codes for colored output not handled correctly with pytest.fail(reason=..., pytrace=False)
#12849
Closed
4 tasks done
Labels
topic: reporting
related to terminal output and user-facing messages and errors
type: bug
problem that needs to be addressed
Comments
RonnyPfannschmidt
added
type: bug
problem that needs to be addressed
topic: reporting
related to terminal output and user-facing messages and errors
labels
Oct 3, 2024
I'm looking into this |
The issue here is that when pytrace=False, the value is passed to Working on a PR to fix this |
6 tasks
nicoddemus
pushed a commit
that referenced
this issue
Nov 25, 2024
- When `ReprEntry.style == "value"` (happens when calling `pytest.fail(..., pytrace=False)`, the message should not be printed to terminal using `TerminalWriter._write_source` because then it'll try to highlight the message as source code - The message should be printed to terminal directly using `TerminalWriter.line` or `TerminalWriter.write`, I went with the later for testing purposes #12959 (comment) Closes #12849
patchback bot
pushed a commit
that referenced
this issue
Nov 25, 2024
- When `ReprEntry.style == "value"` (happens when calling `pytest.fail(..., pytrace=False)`, the message should not be printed to terminal using `TerminalWriter._write_source` because then it'll try to highlight the message as source code - The message should be printed to terminal directly using `TerminalWriter.line` or `TerminalWriter.write`, I went with the later for testing purposes #12959 (comment) Closes #12849 (cherry picked from commit 76e0444)
6 tasks
nicoddemus
pushed a commit
that referenced
this issue
Nov 25, 2024
- When `ReprEntry.style == "value"` (happens when calling `pytest.fail(..., pytrace=False)`, the message should not be printed to terminal using `TerminalWriter._write_source` because then it'll try to highlight the message as source code - The message should be printed to terminal directly using `TerminalWriter.line` or `TerminalWriter.write`, I went with the later for testing purposes #12959 (comment) Closes #12849 (cherry picked from commit 76e0444) Co-authored-by: Leonardus Chen <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
topic: reporting
related to terminal output and user-facing messages and errors
type: bug
problem that needs to be addressed
Description
There seems to be an inconsistency with how ANSI escape codes for colored output are handled in the failure reason when using
pytest.fail()
withpytrace=True
versuspytrace=False
.In the case where
pytrace=True
, the colored output is rendered correctly in the failure message. However, whenpytrace=False
, the ANSI escape codes are not processed, and they partly appear as raw text in the terminal output.Steps to Reproduce
Expected Behavior:
For
pytrace=True
: The ANSI escape codes for blue text (\x1b[34m...
) should render correctly, resulting in the phrase "This should be blue" being displayed in blue.For
pytrace=False
: The ANSI escape codes should still render the text in blue.Actual Behavior:
For
pytrace=True
: The colored output is handled correctly, and the text "This should be blue" is displayed in blue.For
pytrace=False
: The ANSI escape codes are partly displayed as raw text ([34mThis should be blue[0m
), and the text is not colored.Output from running the test
pip list
from the virtual environment you are usingThe text was updated successfully, but these errors were encountered: