diff options
author | Rebecka Gulliksson <rebecka.gulliksson@umu.se> | 2015-08-24 10:27:21 +0200 |
---|---|---|
committer | Rebecka Gulliksson <rebecka.gulliksson@umu.se> | 2015-08-24 10:27:21 +0200 |
commit | d9ed8929ce648d3c8f3547e720d76ad09fc85b99 (patch) | |
tree | 125b7c2025ee0f67a773a32c2de90bc497cfc801 /tests | |
parent | 260c83e398490f63791535b5df8b47d72b2ef42c (diff) | |
download | tox-d9ed8929ce648d3c8f3547e720d76ad09fc85b99.tar.gz |
Added 'voting' testenv attribute.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_config.py | 93 |
1 files changed, 62 insertions, 31 deletions
diff --git a/tests/test_config.py b/tests/test_config.py index 4bdba50..6414bfe 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -32,7 +32,7 @@ class TestVenvConfig: deps= world1 :xyz:http://hello/world - """ % (tmpdir, )) + """ % (tmpdir,)) assert config.toxworkdir == tmpdir assert len(config.envconfigs) == 2 assert config.envconfigs['py1'].envdir == tmpdir.join("py1") @@ -92,12 +92,18 @@ class TestVenvConfig: """ Ensure correct parseini._is_same_dep is working with a few samples. """ - assert DepOption._is_same_dep('pkg_hello-world3==1.0', 'pkg_hello-world3') - assert DepOption._is_same_dep('pkg_hello-world3==1.0', 'pkg_hello-world3>=2.0') - assert DepOption._is_same_dep('pkg_hello-world3==1.0', 'pkg_hello-world3>2.0') - assert DepOption._is_same_dep('pkg_hello-world3==1.0', 'pkg_hello-world3<2.0') - assert DepOption._is_same_dep('pkg_hello-world3==1.0', 'pkg_hello-world3<=2.0') - assert not DepOption._is_same_dep('pkg_hello-world3==1.0', 'otherpkg>=2.0') + assert DepOption._is_same_dep('pkg_hello-world3==1.0', + 'pkg_hello-world3') + assert DepOption._is_same_dep('pkg_hello-world3==1.0', + 'pkg_hello-world3>=2.0') + assert DepOption._is_same_dep('pkg_hello-world3==1.0', + 'pkg_hello-world3>2.0') + assert DepOption._is_same_dep('pkg_hello-world3==1.0', + 'pkg_hello-world3<2.0') + assert DepOption._is_same_dep('pkg_hello-world3==1.0', + 'pkg_hello-world3<=2.0') + assert not DepOption._is_same_dep('pkg_hello-world3==1.0', + 'otherpkg>=2.0') class TestConfigPlatform: @@ -109,7 +115,8 @@ class TestConfigPlatform: assert len(config.envconfigs) == 1 assert config.envconfigs['py1'].platform == "linux2" - def test_config_parse_platform_rex(self, newconfig, mocksession, monkeypatch): + def test_config_parse_platform_rex(self, newconfig, mocksession, + monkeypatch): config = newconfig([], """ [testenv:py1] platform = a123|b123 @@ -126,7 +133,8 @@ class TestConfigPlatform: assert not venv.matching_platform() @pytest.mark.parametrize("plat", ["win", "lin", ]) - def test_config_parse_platform_with_factors(self, newconfig, plat, monkeypatch): + def test_config_parse_platform_with_factors(self, newconfig, plat, + monkeypatch): monkeypatch.setattr(sys, "platform", "win32") config = newconfig([], """ [tox] @@ -273,7 +281,8 @@ class TestIniParser: [mydefault] key2={xyz} """) - reader = SectionReader("mydefault", config._cfg, fallbacksections=['mydefault']) + reader = SectionReader("mydefault", config._cfg, + fallbacksections=['mydefault']) assert reader is not None with py.test.raises(tox.exception.ConfigError): reader.getstring("key2") @@ -285,7 +294,8 @@ class TestIniParser: [section] key=value """) - reader = SectionReader("section", config._cfg, fallbacksections=['mydefault']) + reader = SectionReader("section", config._cfg, + fallbacksections=['mydefault']) x = reader.getstring("key2") assert x == "value2" x = reader.getstring("key3") @@ -300,7 +310,8 @@ class TestIniParser: [section] key={value} """) - reader = SectionReader("section", config._cfg, fallbacksections=['mydefault']) + reader = SectionReader("section", config._cfg, + fallbacksections=['mydefault']) reader.addsubstitutions(value="newvalue", value2="newvalue2") x = reader.getstring("key2") assert x == "newvalue2" @@ -352,7 +363,8 @@ class TestIniParser: with py.test.raises(tox.exception.ConfigError): reader.getstring("key2") - def test_getstring_environment_substitution_with_default(self, monkeypatch, newconfig): + def test_getstring_environment_substitution_with_default(self, monkeypatch, + newconfig): monkeypatch.setenv("KEY1", "hello") config = newconfig(""" [section] @@ -494,7 +506,9 @@ class TestIniParser: x = reader.getargvlist("key2") assert x == [["cmd1", "-f", "foo", "bar baz"]] - def test_positional_arguments_are_only_replaced_when_standing_alone(self, tmpdir, newconfig): + def test_positional_arguments_are_only_replaced_when_standing_alone(self, + tmpdir, + newconfig): config = newconfig(""" [section] key= @@ -521,10 +535,12 @@ class TestIniParser: config = newconfig(inisource) reader = SectionReader("section", config._cfg) posargs = ['hello', 'world'] - reader.addsubstitutions(posargs, envlogdir='ENV_LOG_DIR', envname='ENV_NAME') + reader.addsubstitutions(posargs, envlogdir='ENV_LOG_DIR', + envname='ENV_NAME') expected = [ - 'py.test', '-n5', '--junitxml=ENV_LOG_DIR/junit-ENV_NAME.xml', 'hello', 'world' + 'py.test', '-n5', '--junitxml=ENV_LOG_DIR/junit-ENV_NAME.xml', + 'hello', 'world' ] assert reader.getargvlist('key')[0] == expected @@ -598,6 +614,7 @@ class TestConfigTestEnv: int_hashseed = int(hashseed) # hashseed is random by default, so we can't assert a specific value. assert int_hashseed > 0 + assert envconfig.voting is True def test_sitepackages_switch(self, tmpdir, newconfig): config = newconfig(["--sitepackages"], "") @@ -696,7 +713,8 @@ class TestConfigTestEnv: assert envconfig.setenv['ANOTHER_VAL'] == 'else' @pytest.mark.parametrize("plat", ["win32", "linux2"]) - def test_passenv_as_multiline_list(self, tmpdir, newconfig, monkeypatch, plat): + def test_passenv_as_multiline_list(self, tmpdir, newconfig, monkeypatch, + plat): monkeypatch.setattr(sys, "platform", plat) monkeypatch.setenv("A123A", "a") monkeypatch.setenv("A123B", "b") @@ -726,7 +744,8 @@ class TestConfigTestEnv: assert "A123B" in envconfig.passenv @pytest.mark.parametrize("plat", ["win32", "linux2"]) - def test_passenv_as_space_separated_list(self, tmpdir, newconfig, monkeypatch, plat): + def test_passenv_as_space_separated_list(self, tmpdir, newconfig, + monkeypatch, plat): monkeypatch.setattr(sys, "platform", plat) monkeypatch.setenv("A123A", "a") monkeypatch.setenv("A123B", "b") @@ -1112,7 +1131,7 @@ class TestConfigTestEnv: conf = newconfig([], inisource) configs = conf.envconfigs assert [dep.name for dep in configs['a-x'].deps] == \ - ["dep-all", "dep-a", "dep-x"] + ["dep-all", "dep-a", "dep-x"] assert [dep.name for dep in configs['b'].deps] == ["dep-all", "dep-b"] def test_factor_ops(self, newconfig): @@ -1213,7 +1232,15 @@ class TestConfigTestEnv: configs = newconfig([], inisource).envconfigs assert sorted(configs) == ["py27-django1.6", "py27-django1.7"] assert [d.name for d in configs["py27-django1.6"].deps] \ - == ["Django==1.6"] + == ["Django==1.6"] + + def test_voting(self, newconfig): + inisource = """ + [testenv] + voting=False + """ + config = newconfig([], inisource).envconfigs + assert config["python"].voting is False class TestGlobalOptions: @@ -1334,7 +1361,7 @@ class TestGlobalOptions: """ config = newconfig([], inisource) assert config.envlist == \ - ["py26-dep1", "py26-dep2", "py27-dep1", "py27-dep2"] + ["py26-dep1", "py26-dep2", "py27-dep1", "py27-dep2"] def test_envlist_multiline(self, newconfig): inisource = """ @@ -1345,7 +1372,7 @@ class TestGlobalOptions: """ config = newconfig([], inisource) assert config.envlist == \ - ["py27", "py34"] + ["py27", "py34"] def test_minversion(self, tmpdir, newconfig, monkeypatch): inisource = """ @@ -1355,7 +1382,8 @@ class TestGlobalOptions: config = newconfig([], inisource) assert config.minversion == "3.0" - def test_skip_missing_interpreters_true(self, tmpdir, newconfig, monkeypatch): + def test_skip_missing_interpreters_true(self, tmpdir, newconfig, + monkeypatch): inisource = """ [tox] skip_missing_interpreters = True @@ -1363,7 +1391,8 @@ class TestGlobalOptions: config = newconfig([], inisource) assert config.option.skip_missing_interpreters - def test_skip_missing_interpreters_false(self, tmpdir, newconfig, monkeypatch): + def test_skip_missing_interpreters_false(self, tmpdir, newconfig, + monkeypatch): inisource = """ [tox] skip_missing_interpreters = False @@ -1391,7 +1420,6 @@ class TestGlobalOptions: class TestHashseedOption: - def _get_envconfigs(self, newconfig, args=None, tox_ini=None, make_hashseed=None): if args is None: @@ -1488,6 +1516,7 @@ class TestHashseedOption: def make_hashseed(): next_seed[0] += 1 return str(next_seed[0]) + # Check that make_hashseed() works. assert make_hashseed() == '1001' envconfigs = self._get_envconfigs(newconfig, tox_ini=tox_ini, @@ -1555,11 +1584,11 @@ class TestIndexServer: config = newconfig([], inisource) expected = "file://%s/.pip/downloads/simple" % config.homedir assert config.indexserver['default'].url == expected - assert config.indexserver['local1'].url == config.indexserver['default'].url + assert config.indexserver['local1'].url == config.indexserver[ + 'default'].url class TestParseEnv: - def test_parse_recreate(self, newconfig): inisource = "" config = newconfig([], inisource) @@ -1667,7 +1696,6 @@ def test_env_spec(cmdline, envlist): class TestCommandParser: - def test_command_parser_for_word(self): p = CommandParser('word') # import pytest; pytest.set_trace() @@ -1692,8 +1720,10 @@ class TestCommandParser: p = CommandParser(complex_case) parsed = list(p.words()) expected = [ - 'word', ' ', '[]', ' ', '[literal]', ' ', '{something}', ' ', '{some:other thing}', - ' ', 'w', '{ord}', ' ', 'w', '{or}', 'd', ' ', 'w', '{ord}', ' ', 'w', '{o:rd}', ' ', + 'word', ' ', '[]', ' ', '[literal]', ' ', '{something}', ' ', + '{some:other thing}', + ' ', 'w', '{ord}', ' ', 'w', '{or}', 'd', ' ', 'w', '{ord}', ' ', + 'w', '{o:rd}', ' ', 'w', '{o:r}', 'd', ' ', '{w:or}', 'd', ' ', 'w[]ord', ' ', '{posargs:{a key}}', ] @@ -1711,7 +1741,8 @@ class TestCommandParser: other}""") p = CommandParser(cmd) parsed = list(p.words()) - assert parsed == ['cmd2', ' ', '{posargs:{item2}\n other}'] + assert parsed == ['cmd2', ' ', + '{posargs:{item2}\n other}'] def test_command_parsing_for_issue_10(self): cmd = "nosetests -v -a !deferred --with-doctest []" |