diff options
author | Bernát Gábor <bgabor8@bloomberg.net> | 2019-05-15 17:30:50 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-15 17:30:50 +0100 |
commit | dd6619346306181c7d8313a86afa4ad7be6f2178 (patch) | |
tree | f7a7c5cd971a2fc894aff28ac7b001823f20cd9b /tests | |
parent | bfd22c64acb181955e3e3c126af4aa8da3938828 (diff) | |
download | tox-git-dd6619346306181c7d8313a86afa4ad7be6f2178.tar.gz |
show config now shows all config, filter-able, contains host tox python and package versions (#1298)
and package versions
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/config/test_config.py | 49 | ||||
-rw-r--r-- | tests/unit/session/test_show_config.py | 117 |
2 files changed, 117 insertions, 49 deletions
diff --git a/tests/unit/config/test_config.py b/tests/unit/config/test_config.py index c64ec1be..206fde8d 100644 --- a/tests/unit/config/test_config.py +++ b/tests/unit/config/test_config.py @@ -2722,12 +2722,6 @@ class TestCmdInvocation: assert "some-repr" in version_info assert "1.0" in version_info - def test_config_specific_ini(self, tmpdir, cmd): - ini = tmpdir.ensure("hello.ini") - result = cmd("-c", ini, "--showconfig") - assert not result.ret - assert result.outlines[1] == "config-file: {}".format(ini) - def test_no_tox_ini(self, cmd, initproj): initproj("noini-0.5") result = cmd() @@ -2736,49 +2730,6 @@ class TestCmdInvocation: assert result.err == msg assert not result.out - def test_override_workdir(self, cmd, initproj): - baddir = "badworkdir-123" - gooddir = "overridden-234" - initproj( - "overrideworkdir-0.5", - filedefs={ - "tox.ini": """ - [tox] - toxworkdir={} - """.format( - baddir - ) - }, - ) - result = cmd("--workdir", gooddir, "--showconfig") - assert not result.ret - assert gooddir in result.out - assert baddir not in result.out - assert py.path.local(gooddir).check() - assert not py.path.local(baddir).check() - - def test_showconfig_with_force_dep_version(self, cmd, initproj): - initproj( - "force_dep_version", - filedefs={ - "tox.ini": """ - [tox] - - [testenv] - deps= - dep1==2.3 - dep2 - """ - }, - ) - result = cmd("--showconfig") - result.assert_success(is_run_test_env=False) - assert any(re.match(r".*deps.*dep1==2.3, dep2.*", l) for l in result.outlines) - # override dep1 specific version, and force version for dep2 - result = cmd("--showconfig", "--force-dep=dep1", "--force-dep=dep2==5.0") - result.assert_success(is_run_test_env=False) - assert any(re.match(r".*deps.*dep1, dep2==5.0.*", l) for l in result.outlines) - @pytest.mark.parametrize( "cli_args,run_envlist", diff --git a/tests/unit/session/test_show_config.py b/tests/unit/session/test_show_config.py new file mode 100644 index 00000000..1a01d1d8 --- /dev/null +++ b/tests/unit/session/test_show_config.py @@ -0,0 +1,117 @@ +import py +import pytest +from six import StringIO +from six.moves import configparser + + +def load_config(args, cmd): + result = cmd(*args) + result.assert_success(is_run_test_env=False) + parser = configparser.ConfigParser() + output = StringIO(result.out) + parser.readfp(output) + return parser + + +def test_showconfig_with_force_dep_version(cmd, initproj): + initproj( + "force_dep_version", + filedefs={ + "tox.ini": """ + [tox] + + [testenv] + deps= + dep1==2.3 + dep2 + """ + }, + ) + parser = load_config(("--showconfig",), cmd) + assert parser.get("testenv:python", "deps") == "[dep1==2.3, dep2]" + + parser = load_config(("--showconfig", "--force-dep=dep1", "--force-dep=dep2==5.0"), cmd) + assert parser.get("testenv:python", "deps") == "[dep1, dep2==5.0]" + + +@pytest.fixture() +def setup_mixed_conf(initproj): + initproj( + "force_dep_version", + filedefs={ + "tox.ini": """ + [tox] + envlist = py37,py27,pypi,docs + + [testenv:notincluded] + changedir = whatever + + [testenv:docs] + changedir = docs + """ + }, + ) + + +@pytest.mark.parametrize( + "args, expected", + [ + ( + ["--showconfig"], + [ + "tox", + "tox:versions", + "testenv:py37", + "testenv:py27", + "testenv:pypi", + "testenv:docs", + "testenv:notincluded", + ], + ), + ( + ["--showconfig", "-l"], + [ + "tox", + "tox:versions", + "testenv:py37", + "testenv:py27", + "testenv:pypi", + "testenv:docs", + ], + ), + (["--showconfig", "-e", "py37,py36"], ["testenv:py37", "testenv:py36"]), + ], + ids=["all", "default_only", "-e"], +) +def test_showconfig(cmd, setup_mixed_conf, args, expected): + parser = load_config(args, cmd) + found_sections = parser.sections() + assert found_sections == expected + + +def test_config_specific_ini(tmpdir, cmd): + ini = tmpdir.ensure("hello.ini") + output = load_config(("-c", ini, "--showconfig"), cmd) + assert output.get("tox", "toxinipath") == ini + + +def test_override_workdir(cmd, initproj): + baddir = "badworkdir-123" + gooddir = "overridden-234" + initproj( + "overrideworkdir-0.5", + filedefs={ + "tox.ini": """ + [tox] + toxworkdir={} + """.format( + baddir + ) + }, + ) + result = cmd("--workdir", gooddir, "--showconfig") + assert not result.ret + assert gooddir in result.out + assert baddir not in result.out + assert py.path.local(gooddir).check() + assert not py.path.local(baddir).check() |