-
Notifications
You must be signed in to change notification settings - Fork 1.2k
pytest colored output (with --color=yes) makes the test output log unreadable (by humans) #18119
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
Comments
The same (or a similar) bug was previously reported as #11497 but wasn't fixed because it was judged by @karrtikr to lack details to make it reproducible while the Hopefully the minimal reproducer above should make the cause of the problem clearer. |
This StackOverflow answer might help trim ANSI escape sequences from Python test log outputs: |
This should be addressed as a part of re-writing the test adapter. #17242 Currently we parse the pytest output, that causes this problem. |
Parsing is not the problem: the test runner can complete successfully with green markers everywhere. It's just the display in the "Python Test Log" output view that is unreadable. |
@ogrisel I see, thanks for clarifying. |
We don’t want to trim the color, we want to display the color. |
The |
Color output is now possible on the new testing rewrite! The output will now go to the |
@eleanorjboyd Thank you very much for this update! Just to clarify, by "testing rewrite" you mean – what? Is this something we'll likely see in the next release of the Python extension? :) |
Hello! Sorry for the lack of clarity there, you can read about the rewrite which is under an experiment here: https://devblogs.microsoft.com/python/python-in-visual-studio-code-june-2023-release/ under Test Discovery and Execution Rewrite. To use the rewrite yourself just add Additional information on the change in output can be found here: https://github.com/microsoft/vscode-python/wiki/New-Method-for-Output-Handling-in-Python-Testing |
Thank you very much, @eleanorjboyd! |
Hello, I tried ”python.experiments.optInto": ["pythonTestAdapter"], and I now have colored output in the test result window, which is cool. But noticed:
|
Hello @mehdigmira, I have just returned from vacation and will take a look at this shortly thank you for your detailed notes. one quick question, @connor4312 do you know if the pop up window they are mentioning supports coloring the same way as the test result panel? |
Uh oh!
There was an error while loading. Please reload this page.
VS Code version
1.62.3
Extension version
v2021.11.1422169775
OS type
macOS
OS version
12.0
Python distribution
Other
Python version
3.9
Language server
Pylance
Expected behaviour
I expect the output log in "Python Test Log" to not display the control characters, for instance by stripping them, that is obtaining the following output:
Alternatively, colors could be rendered in the log as they are when running the tests in a shell terminal:
Actual behaviour
The "Python Test Log" displays the color control characters such as
�[32m
without rendering them:Steps to reproduce
Create a new test Python test project, configure a Python interpreter with pytest installed and add a
setup.cfg
file containing:and a test file with a single test function, for instance a file named
test_debug_vscode.py
with the following content:Then:
Then launch the test by clicking on the green
>
icon in the VS Code UI and open the "Python Test Log" output view.Logs
The Python log itself has no problem:
Code of Conduct
The text was updated successfully, but these errors were encountered: