ANSI escape codes for colored output not handled correctly with pytest.fail(reason=..., pytrace=False)
#12849
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: