-
-
Notifications
You must be signed in to change notification settings - Fork 33.1k
gh-140082: Forward colorizing from libregrtest to unittest #140083
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
base: main
Are you sure you want to change the base?
Conversation
libregrtest redirects test output to a file as part of its operation. When `unittest` checks to see if it should colorize with `isatty(sys.stdout)` that fails resulting in no colorizing of the unittest output. Update `libregrtest` to set `FORCE_COLOR=1` when redirecting test output so that unittest will do color printing.
I think this can be skip news as it's a strictly internal change / libregrtest isn't externally exposed |
You might add a NEWS entry in the Tests category. |
Co-authored-by: Victor Stinner <vstinner@python.org>
random.seed(runtests.random_seed) | ||
|
||
if can_colorize(file=sys.stdout): | ||
os.environ['FORCE_COLOR'] = "1" |
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.
This change is not needed to get colors with ./python -m test -W -j0 (...)
command.
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.
Correct, -j0
results in multi-worker mode where this code isn't run, instead the worker.py
code is used. This is only used in single process mode ex. ./python -m test -W --single-process
libregrtest
redirects test output to a file as part of its operation. Whenunittest
checks to see if it should colorize withisatty(sys.stdout)
that returns False resulting in no colorizing of theunittest
output.Update
libregrtest
to setFORCE_COLOR=1
when redirecting test output so thatunittest
will do color printing.python -m test -W
#140082