Skip to content

Commit 538e963

Browse files
jurko-gospodneticgaborbernat
authored andcommitted
Touch up tests (#687)
* touch up existing test * test how environments are recognized based on factors Requested environments are not recognised unless all of their factors are listed somewhere in some read configuration file section or built into tox itself.
1 parent 20215c1 commit 538e963

File tree

1 file changed

+31
-11
lines changed

1 file changed

+31
-11
lines changed

tests/test_config.py

+31-11
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def test_config_parse_platform_rex(self, newconfig, mocksession, monkeypatch):
172172
monkeypatch.undo()
173173
assert not venv.matching_platform()
174174

175-
@pytest.mark.parametrize("plat", ["win", "lin", ])
175+
@pytest.mark.parametrize("plat", ["win", "lin", "osx"])
176176
def test_config_parse_platform_with_factors(self, newconfig, plat, monkeypatch):
177177
monkeypatch.setattr(sys, "platform", "win32")
178178
config = newconfig([], """
@@ -185,7 +185,7 @@ def test_config_parse_platform_with_factors(self, newconfig, plat, monkeypatch):
185185
""")
186186
assert len(config.envconfigs) == 3
187187
platform = config.envconfigs['py27-' + plat].platform
188-
expected = {"win": "win32", "lin": "linux2"}.get(plat)
188+
expected = {"win": "win32", "lin": "linux2", "osx": ""}.get(plat)
189189
assert platform == expected
190190

191191

@@ -526,8 +526,6 @@ def test_argvlist(self, tmpdir, newconfig):
526526
""")
527527
reader = SectionReader("section", config._cfg)
528528
reader.addsubstitutions(item1="with space", item2="grr")
529-
# pytest.raises(tox.exception.ConfigError,
530-
# "reader.getargvlist('key1')")
531529
assert reader.getargvlist('key1') == []
532530
x = reader.getargvlist("key2")
533531
assert x == [["cmd1", "with", "space", "grr"],
@@ -552,8 +550,6 @@ def test_argvlist_multiline(self, tmpdir, newconfig):
552550
""")
553551
reader = SectionReader("section", config._cfg)
554552
reader.addsubstitutions(item1="with space", item2="grr")
555-
# pytest.raises(tox.exception.ConfigError,
556-
# "reader.getargvlist('key1')")
557553
assert reader.getargvlist('key1') == []
558554
x = reader.getargvlist("key2")
559555
assert x == [["cmd1", "with", "space", "grr"]]
@@ -600,17 +596,13 @@ def test_argvlist_positional_substitution(self, tmpdir, newconfig):
600596
reader = SectionReader("section", config._cfg)
601597
posargs = ['hello', 'world']
602598
reader.addsubstitutions(posargs, item2="value2")
603-
# pytest.raises(tox.exception.ConfigError,
604-
# "reader.getargvlist('key1')")
605599
assert reader.getargvlist('key1') == []
606600
argvlist = reader.getargvlist("key2")
607601
assert argvlist[0] == ["cmd1"] + posargs
608602
assert argvlist[1] == ["cmd2"] + posargs
609603

610604
reader = SectionReader("section", config._cfg)
611605
reader.addsubstitutions([], item2="value2")
612-
# pytest.raises(tox.exception.ConfigError,
613-
# "reader.getargvlist('key1')")
614606
assert reader.getargvlist('key1') == []
615607
argvlist = reader.getargvlist("key2")
616608
assert argvlist[0] == ["cmd1"]
@@ -1411,6 +1403,33 @@ def get_deps(env):
14111403
assert get_deps("b-x") == ["dep-a-or-b"]
14121404
assert get_deps("b-y") == ["dep-a-or-b", "dep-ab-and-y"]
14131405

1406+
def test_envconfigs_based_on_factors(self, newconfig):
1407+
inisource = """
1408+
[testenv]
1409+
some-setting=
1410+
a: something
1411+
b,c: something
1412+
d-e: something
1413+
1414+
[unknown-section]
1415+
some-setting=
1416+
eggs: something
1417+
"""
1418+
config = newconfig(["-e spam"], inisource)
1419+
assert not config.envconfigs
1420+
assert config.envlist == ["spam"]
1421+
config = newconfig(["-e eggs"], inisource)
1422+
assert not config.envconfigs
1423+
assert config.envlist == ["eggs"]
1424+
config = newconfig(["-e py3-spam"], inisource)
1425+
assert not config.envconfigs
1426+
assert config.envlist == ["py3-spam"]
1427+
for x in "abcde":
1428+
env = "py3-{}".format(x)
1429+
config = newconfig(["-e {}".format(env)], inisource)
1430+
assert sorted(config.envconfigs) == [env]
1431+
assert config.envlist == [env]
1432+
14141433
def test_default_factors(self, newconfig):
14151434
inisource = """
14161435
[tox]
@@ -1576,6 +1595,8 @@ def test_env_selection(self, tmpdir, newconfig, monkeypatch):
15761595
assert config.envlist == ['py27', 'py35', 'py36']
15771596
config = newconfig(["-eALL"], inisource)
15781597
assert config.envlist == ['py27', 'py35', 'py36']
1598+
config = newconfig(['-espam'], inisource)
1599+
assert config.envlist == ["spam"]
15791600

15801601
def test_py_venv(self, tmpdir, newconfig, monkeypatch):
15811602
config = newconfig(["-epy"], "")
@@ -2308,7 +2329,6 @@ class TestCommandParser:
23082329

23092330
def test_command_parser_for_word(self):
23102331
p = CommandParser('word')
2311-
# import pytest; pytest.set_trace()
23122332
assert list(p.words()) == ['word']
23132333

23142334
def test_command_parser_for_posargs(self):

0 commit comments

Comments
 (0)