diff --git a/docs/changelog/1684.feature.rst b/docs/changelog/1684.feature.rst new file mode 100644 index 000000000..609bfd198 --- /dev/null +++ b/docs/changelog/1684.feature.rst @@ -0,0 +1 @@ +Prevent .tox in envlist - by :user:`jayvdb` diff --git a/src/tox/config/__init__.py b/src/tox/config/__init__.py index b438c5a28..600433201 100644 --- a/src/tox/config/__init__.py +++ b/src/tox/config/__init__.py @@ -1475,6 +1475,11 @@ def _getenvdata(self, reader, config): if not env_list: env_list = all_envs + provision_tox_env = config.provision_tox_env + if config.provision_tox_env in env_list: + msg = "provision_tox_env {} cannot be part of envlist".format(provision_tox_env) + raise tox.exception.ConfigError(msg) + package_env = config.isolated_build_env if config.isolated_build is True and package_env in all_envs: all_envs.remove(package_env) @@ -1482,6 +1487,7 @@ def _getenvdata(self, reader, config): if config.isolated_build is True and package_env in env_list: msg = "isolated_build_env {} cannot be part of envlist".format(package_env) raise tox.exception.ConfigError(msg) + return env_list, all_envs, _split_env(from_config), envlist_explicit @staticmethod diff --git a/tests/unit/config/test_config.py b/tests/unit/config/test_config.py index 68ff8c8c9..fe11224c2 100644 --- a/tests/unit/config/test_config.py +++ b/tests/unit/config/test_config.py @@ -3479,6 +3479,22 @@ def test_commands_with_backslash(self, newconfig): assert envconfig.commands[0] == ["some", r"hello\world"] +def test_provision_tox_env_cannot_be_in_envlist(newconfig, capsys): + inisource = """ + [tox] + envlist = py36,.tox + """ + with pytest.raises( + tox.exception.ConfigError, + match="provision_tox_env .tox cannot be part of envlist", + ): + newconfig([], inisource) + + out, err = capsys.readouterr() + assert not err + assert not out + + def test_isolated_build_env_cannot_be_in_envlist(newconfig, capsys): inisource = """ [tox]