Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed 'AppData' not passed to env by default (#3151) #3160

Merged
merged 5 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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"})
Stefanhg marked this conversation as resolved.
Show resolved Hide resolved
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