From 264d44f3e2c97d6ed5cf194cb78a8bde5f80998c Mon Sep 17 00:00:00 2001 From: Kurt McKee Date: Mon, 1 Jul 2024 11:25:02 -0500 Subject: [PATCH] Add `windir` to the default list of `pass_env` variables on Windows (#3303) --- docs/changelog/3302.bugfix.rst | 1 + src/tox/tox_env/api.py | 1 + tests/session/cmd/test_show_config.py | 4 +++- 3 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 docs/changelog/3302.bugfix.rst diff --git a/docs/changelog/3302.bugfix.rst b/docs/changelog/3302.bugfix.rst new file mode 100644 index 000000000..99249b6cc --- /dev/null +++ b/docs/changelog/3302.bugfix.rst @@ -0,0 +1 @@ +- Add ``windir`` to the default list of Windows ``pass_env`` environment variables. - by :user:`kurtmckee` diff --git a/src/tox/tox_env/api.py b/src/tox/tox_env/api.py index 260252a68..b98ad3b0a 100644 --- a/src/tox/tox_env/api.py +++ b/src/tox/tox_env/api.py @@ -231,6 +231,7 @@ def _default_pass_env(self) -> list[str]: # noqa: PLR6301 "USERPROFILE", # needed for `os.path.expanduser()` "PATHEXT", # needed for discovering executables "MSYSTEM", # controls paths printed format + "WINDIR", # base path to system executables and DLLs ], ) else: # pragma: win32 no cover diff --git a/tests/session/cmd/test_show_config.py b/tests/session/cmd/test_show_config.py index b852a40d0..f2272cda8 100644 --- a/tests/session/cmd/test_show_config.py +++ b/tests/session/cmd/test_show_config.py @@ -137,7 +137,9 @@ def test_pass_env_config_default(tox_project: ToxProjectCreator, stdout_is_atty: + (["SYSTEMDRIVE", "SYSTEMROOT", "TEMP"] if is_win else []) + (["TERM"] if stdout_is_atty else []) + (["TMP", "USERPROFILE"] if is_win else ["TMPDIR"]) - + ["VIRTUALENV_*", "http_proxy", "https_proxy", "no_proxy"] + + ["VIRTUALENV_*"] + + (["WINDIR"] if is_win else []) + + ["http_proxy", "https_proxy", "no_proxy"] ) assert pass_env == expected