Skip to content

Commit 05c23cb

Browse files
committed
Adopt same pass env list as tox 3 has
Signed-off-by: Bernát Gábor <[email protected]>
1 parent 4cf619a commit 05c23cb

File tree

5 files changed

+32
-22
lines changed

5 files changed

+32
-22
lines changed

docs/changelog/1780.bugfix.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Adopt tox 3 base pass env list, by adding:
2+
3+
- on all platforms: ``LANG``, ``LANGUAGE``, ``CURL_CA_BUNDLE``, ``SSL_CERT_FILE`` , ``LD_LIBRARY_PATH`` and ``REQUESTS_CA_BUNLDE``,
4+
- on Windows: ``SYSTEMDRIVE`` - by :user:`gaborbernat`.

src/tox/pytest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,13 +335,13 @@ def assert_out_err(self, out: str, err: str, *, dedent: bool = True, regex: bool
335335
if dedent:
336336
out = textwrap.dedent(out).lstrip()
337337
if regex:
338-
self.matches(out, self.out, re.MULTILINE)
338+
self.matches(out, self.out, re.MULTILINE | re.DOTALL)
339339
else:
340340
assert self.out == out
341341
if dedent:
342342
err = textwrap.dedent(err).lstrip()
343343
if regex:
344-
self.matches(err, self.err, re.MULTILINE)
344+
self.matches(err, self.err, re.MULTILINE | re.DOTALL)
345345
else:
346346
assert self.err == err
347347

src/tox/tox_env/api.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,21 +117,29 @@ def default_set_env(self) -> Dict[str, str]:
117117

118118
def default_pass_env(self) -> List[str]:
119119
env = [
120-
"https_proxy",
121-
"http_proxy",
122-
"no_proxy",
120+
"https_proxy", # HTTP proxy configuration
121+
"http_proxy", # HTTP proxy configuration
122+
"no_proxy", # HTTP proxy configuration
123+
"LANG", # localication
124+
"LANGUAGE", # localication
125+
"CURL_CA_BUNDLE", # curl certificates
126+
"SSL_CERT_FILE", # https certificates
127+
"LD_LIBRARY_PATH", # location of libs
123128
]
124129
if sys.stdout.isatty(): # if we're on a interactive shell pass on the TERM
125130
env.append("TERM")
126131
if sys.platform == "win32": # pragma: win32 cover
127132
env.extend(
128133
[
129-
"TEMP",
130-
"TMP",
134+
"TEMP", # temporary file location
135+
"TMP", # temporary file location
136+
"USERPROFILE", # needed for `os.path.expanduser()`
137+
"PATHEXT", # needed for discovering executables
138+
"MSYSTEM", # controls paths printed format
131139
]
132140
)
133141
else: # pragma: win32 no cover
134-
env.append("TMPDIR")
142+
env.append("TMPDIR") # temporary file location
135143
return env
136144

137145
def setup(self) -> None:

src/tox/tox_env/python/api.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,13 @@ def default_pass_env(self) -> List[str]:
9898
if sys.platform == "win32": # pragma: win32 cover
9999
env.extend(
100100
[
101+
"SYSTEMDRIVE",
101102
"SYSTEMROOT", # needed for python's crypto module
102-
"PATHEXT", # needed for discovering executables
103103
"COMSPEC", # needed for distutils cygwin compiler
104104
"PROCESSOR_ARCHITECTURE", # platform.machine()
105-
"USERPROFILE", # needed for `os.path.expanduser()`
106-
"MSYSTEM", # controls paths printed format
107105
]
108106
)
107+
env.extend(["REQUESTS_CA_BUNDLE"])
109108
return env
110109

111110
def default_base_python(self, conf: "Config", env_name: Optional[str]) -> List[str]:

tests/session/cmd/test_show_config.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,6 @@ def test_show_config_default_run_env(tox_project: ToxProjectCreator, monkeypatch
2727
version = re.escape(Version(__version__).public)
2828

2929
monkeypatch.delenv("TERM", raising=False) # disable conditionally set flag
30-
if sys.platform == "win32": # pragma: win32 cover
31-
p_env = ["COMSPEC", "MSYSTEM", "PATHEXT", "PROCESSOR_ARCHITECTURE", "SYSTEMROOT", "TEMP", "TMP", "USERPROFILE"]
32-
else: # pragma: win32 no cover
33-
p_env = ["TMPDIR"]
34-
p_env.extend(["PIP_*", "VIRTUALENV_*", "http_proxy", "https_proxy", "no_proxy"])
35-
pass_env_str = "\n".join(f" {re.escape(p)}" for p in sorted(p_env))[4:]
3630

3731
expected = rf"""
3832
\[testenv:{name}\]
@@ -45,8 +39,8 @@ def test_show_config_default_run_env(tox_project: ToxProjectCreator, monkeypatch
4539
env_name = {name}
4640
env_dir = {path}{sep}\.tox4{sep}{name}
4741
env_tmp_dir = {path}{sep}\.tox4{sep}{name}{sep}tmp
48-
pass_env =
49-
{pass_env_str}\
42+
pass_env =\
43+
.*
5044
parallel_show_output = False
5145
description =
5246
commands = magic
@@ -146,12 +140,17 @@ def test_pass_env_config_default(tox_project: ToxProjectCreator, stdout_is_atty:
146140
project = tox_project({"tox.ini": ""})
147141
outcome = project.run("c", "-e", "py", "-k", "pass_env")
148142
pass_env = outcome.state.tox_env("py").conf["pass_env"]
143+
is_win = sys.platform == "win32"
149144
expected = (
150-
(["COMSPEC", "MSYSTEM", "PATHEXT"] if sys.platform == "win32" else [])
145+
(["COMSPEC"] if is_win else [])
146+
+ ["CURL_CA_BUNDLE", "LANG", "LANGUAGE", "LD_LIBRARY_PATH"]
147+
+ (["MSYSTEM", "PATHEXT"] if is_win else [])
151148
+ ["PIP_*"]
152-
+ (["PROCESSOR_ARCHITECTURE", "SYSTEMROOT", "TEMP"] if sys.platform == "win32" else [])
149+
+ (["PROCESSOR_ARCHITECTURE"] if is_win else [])
150+
+ ["REQUESTS_CA_BUNDLE", "SSL_CERT_FILE"]
151+
+ (["SYSTEMDRIVE", "SYSTEMROOT", "TEMP"] if is_win else [])
153152
+ (["TERM"] if stdout_is_atty else [])
154-
+ (["TMP", "USERPROFILE"] if sys.platform == "win32" else ["TMPDIR"])
153+
+ (["TMP", "USERPROFILE"] if is_win else ["TMPDIR"])
155154
+ ["VIRTUALENV_*", "http_proxy", "https_proxy", "no_proxy"]
156155
)
157156
assert pass_env == expected

0 commit comments

Comments
 (0)