diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 1f9b8e387..f8d164644 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -36,6 +36,7 @@ Florian Bruhin Florian Preinstorfer Florian Schulze George Alton +Gleb Nikonorov Gonéri Le Bouder Hazal Ozturk Henk-Jaap Wagenaar diff --git a/docs/changelog/1534.bugfix.rst b/docs/changelog/1534.bugfix.rst new file mode 100644 index 000000000..a997d00e0 --- /dev/null +++ b/docs/changelog/1534.bugfix.rst @@ -0,0 +1 @@ +Make the ``passenv`` environment setting case sensitive. - by :user:`gnikonorov` diff --git a/src/tox/config/__init__.py b/src/tox/config/__init__.py index aa6946708..ee448c3f0 100644 --- a/src/tox/config/__init__.py +++ b/src/tox/config/__init__.py @@ -793,7 +793,7 @@ def passenv(testenv_config, value): passenv.add("TMPDIR") for spec in value: for name in os.environ: - if fnmatchcase(name.upper(), spec.upper()): + if fnmatchcase(name, spec): passenv.add(name) return passenv diff --git a/tests/unit/config/test_config.py b/tests/unit/config/test_config.py index dcf27ff30..5b1ce1c6c 100644 --- a/tests/unit/config/test_config.py +++ b/tests/unit/config/test_config.py @@ -1350,6 +1350,21 @@ def test_passenv_from_global_env(self, newconfig, monkeypatch): assert "A1" in env.passenv assert "A2" in env.passenv + def test_passenv_is_case_sensitive(self, newconfig, monkeypatch): + monkeypatch.setenv("FOO", "upper case foo") + monkeypatch.setenv("fOo", "mixed case foo") + monkeypatch.setenv("foo", "lower case foo") + config = newconfig( + """ + [testenv] + passenv=FOO + """, + ) + env = config.envconfigs["python"] + assert "FOO" in env.passenv + assert "fOo" not in env.passenv + assert "foo" not in env.passenv + def test_passenv_glob_from_global_env(self, newconfig, monkeypatch): monkeypatch.setenv("A1", "a1") monkeypatch.setenv("A2", "a2") diff --git a/tests/unit/test_venv.py b/tests/unit/test_venv.py index cc8eb1273..b450678e2 100644 --- a/tests/unit/test_venv.py +++ b/tests/unit/test_venv.py @@ -788,7 +788,7 @@ def test_env_variables_added_to_pcall(tmpdir, mocksession, newconfig, monkeypatc [testenv:python] commands=python -V - passenv = x123 + passenv = X123 setenv = ENV_VAR = value ESCAPED_VAR = \{value\}