Skip to content

Commit

Permalink
Fixed 'AppData' not passed to env by default (#3151) (#3160)
Browse files Browse the repository at this point in the history
Co-authored-by: Decee1 <48594001+Decee1@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
3 people committed Nov 28, 2023
1 parent 576a820 commit b84e9ae
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/changelog/3151.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added 'AppData' to the default passed environment variables on Windows.
1 change: 1 addition & 0 deletions src/tox/tox_env/python/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ def _default_pass_env(self) -> list[str]:
if sys.platform == "win32": # pragma: win32 cover
env.extend(
[
"APPDATA", # Needed for PIP platformsdirs.windows
"PROGRAMDATA", # needed for discovering the VS compiler
"PROGRAMFILES(x86)", # needed for discovering the VS compiler
"PROGRAMFILES", # needed for discovering the VS compiler
Expand Down
8 changes: 5 additions & 3 deletions tests/session/cmd/test_show_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ def test_pass_env_config_default(tox_project: ToxProjectCreator, stdout_is_atty:
pass_env = outcome.env_conf("py")["pass_env"]
is_win = sys.platform == "win32"
expected = (
["CC", "CCSHARED", "CFLAGS"]
[]
+ (["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"]
+ (["MSYSTEM", "NUMBER_OF_PROCESSORS", "PATHEXT"] if is_win else [])
Expand Down Expand Up @@ -262,7 +264,7 @@ def test_show_config_matching_env_section(tox_project: ToxProjectCreator) -> Non


def test_package_env_inherits_from_pkgenv(tox_project: ToxProjectCreator, demo_pkg_inline: Path) -> None:
project = tox_project({"tox.ini": "[pkgenv]\npass_env = A, B\ndeps=C\n D"})
project = tox_project({"tox.ini": "[pkgenv]\npass_env = A, AA\ndeps=C\n D"})
outcome = project.run("c", "--root", str(demo_pkg_inline), "-k", "deps", "pass_env", "-e", "py,.pkg")
outcome.assert_success()
exp = """
Expand All @@ -272,7 +274,7 @@ def test_package_env_inherits_from_pkgenv(tox_project: ToxProjectCreator, demo_p
D
pass_env =
A
B
AA
"""
exp = dedent(exp)
assert exp in outcome.out

0 comments on commit b84e9ae

Please sign in to comment.