Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config: Prevent .tox in envlist #1800

Merged
merged 1 commit into from
Jan 12, 2021
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/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 @@ -3459,6 +3459,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