diff options
| author | Alexander Schepanovski <suor.web@gmail.com> | 2014-07-17 16:27:47 +0800 |
|---|---|---|
| committer | Alexander Schepanovski <suor.web@gmail.com> | 2014-07-17 16:27:47 +0800 |
| commit | d95962973c14568343cafb62be4279d4312d5975 (patch) | |
| tree | aa74797646893b0d8d021907095d8b2164941613 | |
| parent | 1135a2a07207907db8cd24bd6bd5407fa1fe902f (diff) | |
| download | tox-d95962973c14568343cafb62be4279d4312d5975.tar.gz | |
Reimplement defaultenvs as default factors
| -rw-r--r-- | tests/test_config.py | 14 | ||||
| -rw-r--r-- | tox/_config.py | 21 |
2 files changed, 22 insertions, 13 deletions
diff --git a/tests/test_config.py b/tests/test_config.py index 87ed36a..d7a7451 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -850,6 +850,20 @@ class TestConfigTestEnv: assert [dep.name for dep in configs['b'].deps] == \ ["dep-all", "dep-b", "dep-not-a"] + def test_default_factors(self, newconfig): + inisource=""" + [tox] + envlist = py{26,27,33,34}-dep + + [testenv] + deps= + dep: dep + """ + conf = newconfig([], inisource) + configs = conf.envconfigs + for name, config in configs.items(): + assert config.basepython == 'python%s.%s' % (name[2], name[3]) + class TestGlobalOptions: def test_notest(self, newconfig): config = newconfig([], "") diff --git a/tox/_config.py b/tox/_config.py index 0d9f8af..3a12d93 100644 --- a/tox/_config.py +++ b/tox/_config.py @@ -16,13 +16,9 @@ import tox iswin32 = sys.platform == "win32" -defaultenvs = {'jython': 'jython', 'pypy': 'pypy'} -for _name in "py,py24,py25,py26,py27,py30,py31,py32,py33,py34".split(","): - if _name == "py": - basepython = sys.executable - else: - basepython = "python" + ".".join(_name[2:4]) - defaultenvs[_name] = basepython +default_factors = {'jython': 'jython', 'pypy': 'pypy', 'py': sys.executable} +for version in '24,25,26,27,30,31,32,33,34'.split(','): + default_factors['py' + version] = 'python%s.%s' % tuple(version) def parseconfig(args=None, pkg=None): if args is None: @@ -286,7 +282,7 @@ class parseini: # configure testenvs known_factors = self._list_section_factors("testenv") - known_factors.update(defaultenvs) + known_factors.update(default_factors) known_factors.add("python") for name in all_envs: section = testenvprefix + name @@ -311,8 +307,9 @@ class parseini: def _makeenvconfig(self, name, section, subs, config): vc = VenvConfig(envname=name) vc.config = config + factors = set(name.split('-')) reader = IniReader(self._cfg, fallbacksections=["testenv"], - factors=name.split('-')) + factors=factors) reader.addsubstitutions(**subs) vc.develop = not config.option.installpkg and \ reader.getbool(section, "usedevelop", config.option.develop) @@ -321,10 +318,8 @@ class parseini: if reader.getdefault(section, "python", None): raise tox.exception.ConfigError( "'python=' key was renamed to 'basepython='") - if name in defaultenvs: - bp = defaultenvs[name] - else: - bp = sys.executable + bp = next((default_factors[f] for f in factors if f in default_factors), + sys.executable) vc.basepython = reader.getdefault(section, "basepython", bp) vc._basepython_info = config.interpreters.get_info(vc.basepython) reader.addsubstitutions(envdir=vc.envdir, envname=vc.envname, |
