diff options
author | holger krekel <holger@merlinux.eu> | 2015-04-20 21:51:46 +0200 |
---|---|---|
committer | holger krekel <holger@merlinux.eu> | 2015-04-20 21:51:46 +0200 |
commit | 5460ace40a08b880ebce23cee9d62f2d4999790f (patch) | |
tree | 34fc4948097489ba6df6834665640dd85d127ea0 /tests | |
parent | 406d45d0ef7a5c7baab6db6621dadc5c2c6822a3 (diff) | |
download | tox-5460ace40a08b880ebce23cee9d62f2d4999790f.tar.gz |
introduce new "platform" setting for tox
(XXX) consider using environment marker syntax
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_config.py | 46 | ||||
-rw-r--r-- | tests/test_z_cmdline.py | 18 |
2 files changed, 64 insertions, 0 deletions
diff --git a/tests/test_config.py b/tests/test_config.py index f957771..758db48 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -7,6 +7,7 @@ import tox import tox._config from tox._config import * # noqa from tox._config import _split_env +from tox._venv import VirtualEnv class TestVenvConfig: @@ -18,6 +19,7 @@ class TestVenvConfig: assert config.toxworkdir.realpath() == tmpdir.join(".tox").realpath() assert config.envconfigs['py1'].basepython == sys.executable assert config.envconfigs['py1'].deps == [] + assert not config.envconfigs['py1'].platform def test_config_parsing_multienv(self, tmpdir, newconfig): config = newconfig([], """ @@ -98,6 +100,50 @@ class TestVenvConfig: assert parseini._is_same_dep('pkg_hello-world3==1.0', 'pkg_hello-world3<=2.0') assert not parseini._is_same_dep('pkg_hello-world3==1.0', 'otherpkg>=2.0') + +class TestConfigPlatform: + def test_config_parse_platform(self, newconfig): + config = newconfig([], """ + [testenv:py1] + platform = linux2 + """) + assert len(config.envconfigs) == 1 + assert config.envconfigs['py1'].platform == "linux2" + + def test_config_parse_platform_rex(self, newconfig, mocksession, monkeypatch): + config = newconfig([], """ + [testenv:py1] + platform = a123|b123 + """) + assert len(config.envconfigs) == 1 + envconfig = config.envconfigs['py1'] + venv = VirtualEnv(envconfig, session=mocksession) + assert not venv.matching_platform() + monkeypatch.setattr(sys, "platform", "a123") + assert venv.matching_platform() + monkeypatch.setattr(sys, "platform", "b123") + assert venv.matching_platform() + monkeypatch.undo() + assert not venv.matching_platform() + + + @pytest.mark.parametrize("plat", ["win", "lin", ]) + def test_config_parse_platform_with_factors(self, newconfig, plat, monkeypatch): + monkeypatch.setattr(sys, "platform", "win32") + config = newconfig([], """ + [tox] + envlist = py27-{win,lin,osx} + [testenv] + platform = + win: win32 + lin: linux2 + """) + assert len(config.envconfigs) == 3 + platform = config.envconfigs['py27-' + plat].platform + expected = {"win": "win32", "lin": "linux2"}.get(plat) + assert platform == expected + + class TestConfigPackage: def test_defaults(self, tmpdir, newconfig): config = newconfig([], "") diff --git a/tests/test_z_cmdline.py b/tests/test_z_cmdline.py index 0c145be..391bc4b 100644 --- a/tests/test_z_cmdline.py +++ b/tests/test_z_cmdline.py @@ -242,6 +242,24 @@ def test_unknown_interpreter(cmd, initproj): "*ERROR*InterpreterNotFound*xyz_unknown_interpreter*", ]) +def test_skip_platform_mismatch(cmd, initproj): + initproj("interp123-0.5", filedefs={ + 'tests': {'test_hello.py': "def test_hello(): pass"}, + 'tox.ini': ''' + [testenv] + changedir=tests + platform=x123 + ''' + }) + result = cmd.run("tox") + assert not result.ret + assert "platform mismatch" not in result.stdout.str() + result = cmd.run("tox", "-v") + assert not result.ret + result.stdout.fnmatch_lines([ + "*python*platform mismatch*" + ]) + def test_skip_unknown_interpreter(cmd, initproj): initproj("interp123-0.5", filedefs={ 'tests': {'test_hello.py': "def test_hello(): pass"}, |