From f524cefd0b32d8ab95e7d378fbd9be4cda9d31ed Mon Sep 17 00:00:00 2001 From: John Vandenberg Date: Mon, 11 Jan 2021 00:22:08 +0800 Subject: [PATCH 1/2] test_config: Add test for indirect install_command Problem identified in https://github.com/tox-dev/tox/issues/1777 --- tests/unit/config/test_config.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/unit/config/test_config.py b/tests/unit/config/test_config.py index 0fd23f4f1..f7fa07b0d 100644 --- a/tests/unit/config/test_config.py +++ b/tests/unit/config/test_config.py @@ -1627,6 +1627,26 @@ def test_install_command_substitutions(self, newconfig): ] assert envconfig.install_command == expected_deps + def test_install_command_substitutions_other_section(self, newconfig): + config = newconfig( + """ + [base] + install_command=some_install --arg={toxinidir}/foo \ + {envname} {opts} {packages} + [testenv] + install_command={[base]install_command} + """, + ) + envconfig = config.envconfigs["python"] + expected_deps = [ + "some_install", + "--arg={}/foo".format(config.toxinidir), + "python", + "{opts}", + "{packages}", + ] + assert envconfig.install_command == expected_deps + def test_pip_pre(self, newconfig): config = newconfig( """ From 352bedcfde9e1fe1523318a922576775e0ee93c2 Mon Sep 17 00:00:00 2001 From: John Vandenberg Date: Mon, 11 Jan 2021 08:27:09 +0800 Subject: [PATCH 2/2] config: Revert removal of {packages}/{opts} hack This was removed in e4d0d600, and replaced with a neater approach, however the newer approach doesnt work for replacements from other sections. Fixes https://github.com/tox-dev/tox/issues/1777 --- docs/changelog/1777.bugfix.rst | 1 + src/tox/config/__init__.py | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100644 docs/changelog/1777.bugfix.rst diff --git a/docs/changelog/1777.bugfix.rst b/docs/changelog/1777.bugfix.rst new file mode 100644 index 000000000..d938fbae6 --- /dev/null +++ b/docs/changelog/1777.bugfix.rst @@ -0,0 +1 @@ +Fix regression that broke using install_command in config replacements - by :user:`jayvdb` diff --git a/src/tox/config/__init__.py b/src/tox/config/__init__.py index 7b91250ed..0f6fdbe8c 100644 --- a/src/tox/config/__init__.py +++ b/src/tox/config/__init__.py @@ -1848,6 +1848,12 @@ def _replace_match(self, match): return os.pathsep default_value = g["default_value"] + # special case: opts and packages. Leave {opts} and + # {packages} intact, they are replaced manually in + # _venv.VirtualEnv.run_install_command. + if sub_value in ("opts", "packages"): + return "{{{}}}".format(sub_value) + if sub_value == "posargs": return self.reader.getposargs(default_value)