gh-130293: Ensure test__colorize will pass on dumb terminals. (#130333)

Ensure colorize tests will run on dumb terminals (or environment with TERM=dumb set)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
This commit is contained in:
Russell Keith-Magee 2025-02-20 14:49:18 +08:00 committed by GitHub
parent ee337bea01
commit 1b070060c0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 4 additions and 2 deletions

View file

@ -10,7 +10,7 @@ from test.support.os_helper import EnvironmentVarGuard
@contextlib.contextmanager
def clear_env():
with EnvironmentVarGuard() as mock_env:
for var in "FORCE_COLOR", "NO_COLOR", "PYTHON_COLORS":
for var in "FORCE_COLOR", "NO_COLOR", "PYTHON_COLORS", "TERM":
mock_env.unset(var)
yield mock_env

View file

@ -0,0 +1,2 @@
The tests of terminal colorization are no longer sensitive to the value of
the ``TERM`` variable in the testing environment.

View file

@ -28,7 +28,7 @@
// Xcode log can't display color. Stdout will report that it is *not* a
// TTY.
setenv("NO_COLOR", "1", true);
setenv("PY_COLORS", "0", true);
setenv("PYTHON_COLORS", "0", true);
// Arguments to pass into the test suite runner.
// argv[0] must identify the process; any subsequent arg