Skip to content

Commit b84e9ae

Browse files
Fixed 'AppData' not passed to env by default (#3151) (#3160)
Co-authored-by: Decee1 <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 576a820 commit b84e9ae

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

docs/changelog/3151.bugfix.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Added 'AppData' to the default passed environment variables on Windows.

src/tox/tox_env/python/api.py

+1
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ def _default_pass_env(self) -> list[str]:
118118
if sys.platform == "win32": # pragma: win32 cover
119119
env.extend(
120120
[
121+
"APPDATA", # Needed for PIP platformsdirs.windows
121122
"PROGRAMDATA", # needed for discovering the VS compiler
122123
"PROGRAMFILES(x86)", # needed for discovering the VS compiler
123124
"PROGRAMFILES", # needed for discovering the VS compiler

tests/session/cmd/test_show_config.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,9 @@ def test_pass_env_config_default(tox_project: ToxProjectCreator, stdout_is_atty:
119119
pass_env = outcome.env_conf("py")["pass_env"]
120120
is_win = sys.platform == "win32"
121121
expected = (
122-
["CC", "CCSHARED", "CFLAGS"]
122+
[]
123+
+ (["APPDATA"] if is_win else [])
124+
+ ["CC", "CCSHARED", "CFLAGS"]
123125
+ (["COMSPEC"] if is_win else [])
124126
+ ["CPPFLAGS", "CURL_CA_BUNDLE", "CXX", "HOME", "LANG", "LANGUAGE", "LDFLAGS", "LD_LIBRARY_PATH"]
125127
+ (["MSYSTEM", "NUMBER_OF_PROCESSORS", "PATHEXT"] if is_win else [])
@@ -262,7 +264,7 @@ def test_show_config_matching_env_section(tox_project: ToxProjectCreator) -> Non
262264

263265

264266
def test_package_env_inherits_from_pkgenv(tox_project: ToxProjectCreator, demo_pkg_inline: Path) -> None:
265-
project = tox_project({"tox.ini": "[pkgenv]\npass_env = A, B\ndeps=C\n D"})
267+
project = tox_project({"tox.ini": "[pkgenv]\npass_env = A, AA\ndeps=C\n D"})
266268
outcome = project.run("c", "--root", str(demo_pkg_inline), "-k", "deps", "pass_env", "-e", "py,.pkg")
267269
outcome.assert_success()
268270
exp = """
@@ -272,7 +274,7 @@ def test_package_env_inherits_from_pkgenv(tox_project: ToxProjectCreator, demo_p
272274
D
273275
pass_env =
274276
A
275-
B
277+
AA
276278
"""
277279
exp = dedent(exp)
278280
assert exp in outcome.out

0 commit comments

Comments
 (0)