Skip to content

Commit

Permalink
Always pass FORCE_COLOR & NO_COLOR to the environment
Browse files Browse the repository at this point in the history
The environment variables `FORCE_COLOR` and `NO_COLOR`are a popular way
to force or disable color output. An example usage is pytest being run
under a CI system.
  • Loading branch information
hashar committed Dec 17, 2023
1 parent 383845a commit c4e868b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/changelog/3171.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Always ``PY_COLORS`` to the environment
2 changes: 2 additions & 0 deletions src/tox/tox_env/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ def _default_pass_env(self) -> list[str]:
"LD_LIBRARY_PATH", # location of libs
"LDFLAGS", # linker flags
"HOME", # needed for `os.path.expanduser()` on non-Windows systems
"FORCE_COLOR", # force color output
"NO_COLOR", # disable color output
]
if sys.stdout.isatty(): # if we're on a interactive shell pass on the TERM
env.append("TERM")
Expand Down
3 changes: 2 additions & 1 deletion tests/session/cmd/test_show_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ def test_pass_env_config_default(tox_project: ToxProjectCreator, stdout_is_atty:
+ (["APPDATA"] if is_win else [])
+ ["CC", "CCSHARED", "CFLAGS"]
+ (["COMSPEC"] if is_win else [])
+ ["CPPFLAGS", "CURL_CA_BUNDLE", "CXX", "HOME", "LANG", "LANGUAGE", "LDFLAGS", "LD_LIBRARY_PATH"]
+ ["CPPFLAGS", "CURL_CA_BUNDLE", "CXX", "FORCE_COLOR", "HOME", "LANG"]
+ ["LANGUAGE", "LDFLAGS", "LD_LIBRARY_PATH", "NO_COLOR"]
+ (["MSYSTEM", "NUMBER_OF_PROCESSORS", "PATHEXT"] if is_win else [])
+ ["PIP_*", "PKG_CONFIG", "PKG_CONFIG_PATH", "PKG_CONFIG_SYSROOT_DIR"]
+ (["PROCESSOR_ARCHITECTURE"] if is_win else [])
Expand Down

0 comments on commit c4e868b

Please sign in to comment.