Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/changelog/2182.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix env variable substitutions with defaults containing colon (e.g. URL) -- by :user:`comabrewer`.
2 changes: 1 addition & 1 deletion src/tox/config/loader/ini/replace.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def replace_env(conf: "Config", env_name: Optional[str], args: List[str], chain:
if key in os.environ:
return os.environ[key]

return "" if len(args) == 1 else args[1]
return "" if len(args) == 1 else ":".join(args[1:])


def replace_tty(args: List[str]) -> str:
Expand Down
7 changes: 7 additions & 0 deletions tests/config/loader/ini/replace/test_replace_env_var.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,10 @@ def test_replace_env_var_circular(replace_one: ReplaceOne, monkeypatch: MonkeyPa
monkeypatch.setenv("MAGIC", "{env:MAGIC}")
result = replace_one("{env:MAGIC}")
assert result == "{env:MAGIC}"


def test_replace_env_default_with_colon(replace_one: ReplaceOne, monkeypatch: MonkeyPatch) -> None:
"""If we have a factor that is not specified within the core env-list then that's also an environment"""
monkeypatch.delenv("MAGIC", raising=False)
result = replace_one("{env:MAGIC:https://some.url.org}")
assert result == "https://some.url.org"