Skip to content

Make the passenv environment setting case sensitive #1718

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Florian Bruhin
Florian Preinstorfer
Florian Schulze
George Alton
Gleb Nikonorov
Gonéri Le Bouder
Hazal Ozturk
Henk-Jaap Wagenaar
Expand Down
1 change: 1 addition & 0 deletions docs/changelog/1534.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Make the ``passenv`` environment setting case sensitive. - by :user:`gnikonorov`
2 changes: 1 addition & 1 deletion src/tox/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
15 changes: 15 additions & 0 deletions tests/unit/config/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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\}
Expand Down