From 8e4af1185745da614524c23a5ebad24bc0b44a65 Mon Sep 17 00:00:00 2001 From: Isaac Pedisich Date: Thu, 20 May 2021 15:35:00 -0500 Subject: [PATCH 1/4] Prevent modification of previsioned envdir when using --devenv --- src/tox/config/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tox/config/__init__.py b/src/tox/config/__init__.py index b014d7751..0d9123598 100644 --- a/src/tox/config/__init__.py +++ b/src/tox/config/__init__.py @@ -595,7 +595,7 @@ def tox_addoption(parser): ) def _set_envdir_from_devenv(testenv_config, value): - if testenv_config.config.option.devenv is not None: + if testenv_config.config.option.devenv is not None and testenv_config.envname != ".tox": return py.path.local(testenv_config.config.option.devenv) else: return value From 99930e7023df8f8f18f34cbf3680bf809fba5a50 Mon Sep 17 00:00:00 2001 From: Isaac Pedisich Date: Thu, 20 May 2021 16:28:40 -0500 Subject: [PATCH 2/4] Add test to ensure that --devenv does not change provisioning directory --- tests/unit/session/test_provision.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/unit/session/test_provision.py b/tests/unit/session/test_provision.py index cf2ded108..ad9f2310f 100644 --- a/tests/unit/session/test_provision.py +++ b/tests/unit/session/test_provision.py @@ -385,3 +385,20 @@ def space_path2url(path): if " " not in at_path: return at_path return urljoin("file:", pathname2url(os.path.abspath(at_path))) + + +def test_provision_does_not_occur_in_devenv(newconfig, next_tox_major): + """Adding --devenv should not change the directory where provisioning occurs""" + with pytest.raises(MissingRequirement) as context: + newconfig( + ["--devenv", "my_devenv"], + """\ + [tox] + minversion = {} + """.format( + next_tox_major, + ), + ) + config = context.value.config + assert config.run_provision is True + assert config.envconfigs[".tox"].envdir.basename != "my_devenv" From 868c59aa53fdb40c027310a0dfc647b143d2e719 Mon Sep 17 00:00:00 2001 From: Isaac Pedisich Date: Sun, 23 May 2021 09:55:35 -0500 Subject: [PATCH 3/4] Read provision_tox_env from config rather than assuming it is unchanged --- src/tox/config/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/tox/config/__init__.py b/src/tox/config/__init__.py index 0d9123598..8f03f3647 100644 --- a/src/tox/config/__init__.py +++ b/src/tox/config/__init__.py @@ -595,7 +595,10 @@ def tox_addoption(parser): ) def _set_envdir_from_devenv(testenv_config, value): - if testenv_config.config.option.devenv is not None and testenv_config.envname != ".tox": + if ( + testenv_config.config.option.devenv is not None + and testenv_config.envname != testenv_config.config.provision_tox_env + ): return py.path.local(testenv_config.config.option.devenv) else: return value From f946a9cb67b1ab0e1f4e3bcaf8e466d6479ce2d6 Mon Sep 17 00:00:00 2001 From: Isaac Pedisich Date: Sun, 23 May 2021 09:56:03 -0500 Subject: [PATCH 4/4] Add changelog entry and contributor for #2065 --- CONTRIBUTORS | 1 + docs/changelog/2065.bugfix.rst | 1 + 2 files changed, 2 insertions(+) create mode 100644 docs/changelog/2065.bugfix.rst diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 38e8700e0..8a6e9cba5 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -47,6 +47,7 @@ Ian Stapleton Cordasco Igor Duarte Cardoso Ilya Kulakov Ionel Maries Cristian +Isaac Pedisich Itxaka Serrano Jake Windle Jannis Leidel diff --git a/docs/changelog/2065.bugfix.rst b/docs/changelog/2065.bugfix.rst new file mode 100644 index 000000000..ecb90308e --- /dev/null +++ b/docs/changelog/2065.bugfix.rst @@ -0,0 +1 @@ +``--devenv`` no longer modifies the directory in which the ``.tox`` environment is provisioned - by :user:`isaac-ped`