gh-127873: Only check sys.flags.ignore_environment for PYTHON* env vars#127877
gh-127873: Only check sys.flags.ignore_environment for PYTHON* env vars#127877hugovk merged 15 commits intopython:mainfrom
sys.flags.ignore_environment for PYTHON* env vars#127877Conversation
This comment was marked as resolved.
This comment was marked as resolved.
|
@pablogsal Please could you have a look at this? Thanks! |
|
Why do we use names without the |
Yes, see https://force-color.org/ and https://no-color.org. |
Updated to use |
serhiy-storchaka
left a comment
There was a problem hiding this comment.
LGTM. Although you can use support.force_not_colorized_test_class in few more files.
|
Thank you for the reviews! |
|
Thanks @hugovk for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13. |
|
Sorry, @hugovk, I could not cleanly backport this to |
… `PYTHON*` env vars (pythonGH-127877) (cherry picked from commit 05d12ee) Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
|
GH-129138 is a backport of this pull request to the 3.13 branch. |
When
-Eis passed (and thereforesys.flags.ignore_environmentis true), we should only ignore only env vars matchingPYTHON*; in this case, onlyPYTHON_COLORS.We should not ignore the other env vars:
FORCE_COLOR/NO_COLOR/TERM.Re: https://docs.python.org/3/using/cmdline.html#cmdoption-E
Fixing this revealed some tests that failed because of inserted colour codes. For example, in "ZeroDivisionError: division by zero", the parts "ZeroDivisionError", ":" and "division by zero" are all different colours.
For these test cases, I wrapped them with the
@force_not_colorizeddecorator, or, where there were a number of them, I wrapped the test class in the newforce_not_colorized_test_classdecorator. This was a suggestion from #127223 (comment). And from that PR, I replaced some of the numerous function decorators with the class decorator.can_colorize()ignoresFORCE_COLOR/NO_COLOR/TERMwhen-Eis set #127873