Skip to content

Commit d216ab4

Browse files
committed
Always pass PY_COLORS to the environment
The environment variable is a popular way to force color output, an example being pytest being run under a CI system.
1 parent 383845a commit d216ab4

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

docs/changelog/3171.feature.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Always ``PY_COLORS`` to the environment

src/tox/tox_env/api.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,8 @@ def _default_pass_env(self) -> list[str]:
219219
"LD_LIBRARY_PATH", # location of libs
220220
"LDFLAGS", # linker flags
221221
"HOME", # needed for `os.path.expanduser()` on non-Windows systems
222+
"FORCE_COLOR", # force color output
223+
"NO_COLOR", # disable color output
222224
]
223225
if sys.stdout.isatty(): # if we're on a interactive shell pass on the TERM
224226
env.append("TERM")

tests/session/cmd/test_show_config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ def test_pass_env_config_default(tox_project: ToxProjectCreator, stdout_is_atty:
123123
+ (["APPDATA"] if is_win else [])
124124
+ ["CC", "CCSHARED", "CFLAGS"]
125125
+ (["COMSPEC"] if is_win else [])
126-
+ ["CPPFLAGS", "CURL_CA_BUNDLE", "CXX", "HOME", "LANG", "LANGUAGE", "LDFLAGS", "LD_LIBRARY_PATH"]
126+
+ ["CPPFLAGS", "CURL_CA_BUNDLE", "CXX", "FORCE_COLOR", "HOME", "LANG"]
127+
+ ["LANGUAGE", "LDFLAGS", "LD_LIBRARY_PATH", "NO_COLOR"]
127128
+ (["MSYSTEM", "NUMBER_OF_PROCESSORS", "PATHEXT"] if is_win else [])
128129
+ ["PIP_*", "PKG_CONFIG", "PKG_CONFIG_PATH", "PKG_CONFIG_SYSROOT_DIR"]
129130
+ (["PROCESSOR_ARCHITECTURE"] if is_win else [])

0 commit comments

Comments
 (0)