Skip to content

Commit 88d28c1

Browse files
medmundsgaborbernat
authored andcommitted
Fix missing error for tox -e unknown when tox.ini declares envlist. (#1165)
* Fix missing error for `tox -e unknown` when tox.ini declares envlist. Fixes #1160. * fix_lint (not just fix-lint)
1 parent c8049c7 commit 88d28c1

File tree

4 files changed

+26
-1
lines changed

4 files changed

+26
-1
lines changed

docs/changelog/1160.bugfix.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix missing error for ``tox -e unknown`` when tox.ini declares ``envlist``. - by :user:`medmunds`

src/tox/config/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1053,7 +1053,7 @@ def __init__(self, config, ini_path, ini_data): # noqa
10531053
# factors stated in config envlist
10541054
stated_envlist = reader.getstring("envlist", replace=False)
10551055
if stated_envlist:
1056-
for env in config.envlist:
1056+
for env in _split_env(stated_envlist):
10571057
known_factors.update(env.split("-"))
10581058

10591059
# configure testenvs

tests/unit/config/test_config.py

+9
Original file line numberDiff line numberDiff line change
@@ -2147,6 +2147,15 @@ def test_py_venv(self, newconfig):
21472147
env = config.envconfigs["py"]
21482148
assert str(env.basepython) == sys.executable
21492149

2150+
def test_no_implicit_venv_from_cli_with_envlist(self, newconfig):
2151+
# See issue 1160.
2152+
inisource = """
2153+
[tox]
2154+
envlist = stated-factors
2155+
"""
2156+
config = newconfig(["-etypo-factor"], inisource)
2157+
assert "typo-factor" not in config.envconfigs
2158+
21502159
def test_correct_basepython_chosen_from_default_factors(self, newconfig):
21512160
envlist = list(tox.PYTHON.DEFAULT_FACTORS.keys())
21522161
config = newconfig([], "[tox]\nenvlist={}".format(", ".join(envlist)))

tests/unit/test_z_cmdline.py

+15
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,21 @@ def test_unknown_environment(cmd, initproj):
280280
assert result.out == "ERROR: unknown environment 'qpwoei'\n"
281281

282282

283+
def test_unknown_environment_with_envlist(cmd, initproj):
284+
initproj(
285+
"pkg123",
286+
filedefs={
287+
"tox.ini": """
288+
[tox]
289+
envlist = py{36,37}-django{20,21}
290+
"""
291+
},
292+
)
293+
result = cmd("-e", "py36-djagno21")
294+
assert result.ret, "{}\n{}".format(result.err, result.out)
295+
assert result.out == "ERROR: unknown environment 'py36-djagno21'\n"
296+
297+
283298
def test_minimal_setup_py_empty(cmd, initproj):
284299
initproj(
285300
"pkg123-0.7",

0 commit comments

Comments
 (0)