Skip to content

Commit 31dc5b1

Browse files
poggenhansFabian Poggenhans
and
Fabian Poggenhans
authored
Passenv: Include default env variables regardless of their case on UNIX (#2378)
Co-authored-by: Fabian Poggenhans <[email protected]>
1 parent 465cb98 commit 31dc5b1

File tree

5 files changed

+14
-2
lines changed

5 files changed

+14
-2
lines changed

CONTRIBUTORS

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ David Diaz
3535
Ederag
3636
Eli Collins
3737
Eugene Yunak
38+
Fabian Poggenhans
3839
Felix Hildén
3940
Fernando L. Pereira
4041
Florian Bruhin

docs/changelog/2372.feature.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add default environment variables (such as http_proxy) regardless of their case to passenv on UNIX -- by :user:`poggenhans`.

docs/config.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,8 @@ Complete list of settings that you can put into ``testenv*`` sections:
460460
``A`` will pass both ``A`` and ``a``.
461461

462462
Some variables are always passed through to ensure the basic functionality
463-
of standard library functions or tooling like pip:
463+
of standard library functions or tooling like pip.
464+
This is also not case sensitive on all platforms except Windows:
464465

465466
* passed through on all platforms: ``CURL_CA_BUNDLE``, ``PATH``,
466467
``LANG``, ``LANGUAGE``,

src/tox/config/__init__.py

+4
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,10 @@ def passenv(testenv_config, value):
809809
passenv.add("MSYSTEM") # fixes #429
810810
else:
811811
passenv.add("TMPDIR")
812+
813+
# add non-uppercased variables to passenv if present (only necessary for UNIX)
814+
passenv.update(name for name in os.environ if name.upper() in passenv)
815+
812816
for spec in value:
813817
for name in os.environ:
814818
if fnmatchcase(name.upper(), spec.upper()):

tests/unit/config/test_config.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -1494,6 +1494,8 @@ def test_passenv_as_multiline_list(self, newconfig, monkeypatch, plat):
14941494
monkeypatch.setenv("A123A", "a")
14951495
monkeypatch.setenv("A123B", "b")
14961496
monkeypatch.setenv("BX23", "0")
1497+
if plat == "linux2":
1498+
monkeypatch.setenv("http_proxy", "c")
14971499
config = newconfig(
14981500
"""
14991501
[testenv]
@@ -1518,6 +1520,9 @@ def test_passenv_as_multiline_list(self, newconfig, monkeypatch, plat):
15181520
assert "MSYSTEM" in envconfig.passenv
15191521
else:
15201522
assert "TMPDIR" in envconfig.passenv
1523+
if sys.platform != "win32":
1524+
# this cannot be emulated on win - it doesn't support lowercase env vars
1525+
assert "http_proxy" in envconfig.passenv
15211526
assert "CURL_CA_BUNDLE" in envconfig.passenv
15221527
assert "PATH" in envconfig.passenv
15231528
assert "PIP_INDEX_URL" in envconfig.passenv
@@ -3575,7 +3580,7 @@ def test_config_via_pyproject_legacy(initproj):
35753580
initproj(
35763581
"config_via_pyproject_legacy-0.5",
35773582
filedefs={
3578-
"pyproject.toml": u'''
3583+
"pyproject.toml": '''
35793584
[project]
35803585
description = "Factory ⸻ A code generator 🏭"
35813586
authors = [{name = "Łukasz Langa"}]

0 commit comments

Comments
 (0)