Skip to content

Commit

Permalink
config: Prevent .tox in envlist
Browse files Browse the repository at this point in the history
Fixes #1684
  • Loading branch information
jayvdb authored and gaborbernat committed Jan 12, 2021
1 parent ff4bd47 commit 4b44584
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/changelog/1684.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Prevent .tox in envlist - by :user:`jayvdb`
6 changes: 6 additions & 0 deletions src/tox/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1475,13 +1475,19 @@ 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)

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
Expand Down
16 changes: 16 additions & 0 deletions tests/unit/config/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 4b44584

Please sign in to comment.