Question
How can the color of the "OK" test result output in PyCharm be changed from red to green?
Answer
In PyCharm, test results are color-coded by their output stream (stdout or stderr), rather than their pass or fail status. Here's why this happens and what can be done:
-
The "OK" message in your unit test results appears in red because it is output via the standard error stream (stderr) by Python's
unittestmodule. PyCharm visually distinguishes stderr output in red, irrespective of the actual content or result of the tests. -
There is no setting in PyCharm to change the "OK" result to green while maintaining red for true failures because the color-coding is stream-based, not content-based.
If the red coloring of "OK" bothers you, you can change the appearance of all stderr output:
- Navigate to Settings | Editor | Color Scheme | Console Colors.
- Adjust the color for "std err" to something more neutral or change it to green.
Important Note: Changing the stderr color will affect all stderr output, including genuine errors and failures, which might make troubleshooting more difficult.
Alternative Solution: You can rely on the visual indicators provided by PyCharm, such as:
- The green check mark in the Test Results panel.
- The "n tests passed" status and the green bar at the top of the Test Results panel.
Feature Request: A feature request has been filed to improve how test result colors are handled: PY-90602. You can follow and vote on it to support development of more granular color-coding by test result instead of by stream.
Feel free to reach out if you have any further questions or need additional assistance.
Comments
0 comments
Please sign in to leave a comment.