diff options
-rw-r--r-- | CHANGELOG | 17 | ||||
-rw-r--r-- | CONTRIBUTORS | 1 | ||||
-rw-r--r-- | setup.cfg | 13 | ||||
-rw-r--r-- | setup.py | 2 | ||||
-rw-r--r-- | tests/test_config.py | 54 | ||||
-rw-r--r-- | tox/__init__.py | 2 | ||||
-rw-r--r-- | tox/config.py | 47 |
7 files changed, 113 insertions, 23 deletions
@@ -1,3 +1,20 @@ +2.1.2 (dev) +----------- + +- fix issue265 and add LD_LIBRARY_PATH to passenv on linux by default + because otherwise the python interpreter might not start up in + certain configurations (redhat software collections). Thanks David Riddle. + +- fix issue246: fix regression in config parsing by reordering + such that {envbindir} can be used again in tox.ini. Thanks Olli Walsh. + +- fix issue99: the {env:...} substitution now properly uses environment + settings from the ``setenv`` section. Thanks Itxaka Serrano. + +- fix issue281: make --force-deps work when urls are present in + dependency configs. Thanks Glyph Lefkowitz for reporting. + + 2.1.1 ---------- diff --git a/CONTRIBUTORS b/CONTRIBUTORS index b3e523e..75a2dd8 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -31,3 +31,4 @@ Marc Schlaich Clark Boylan Eugene Yunak Mark Hirota +Itxaka Serrano @@ -1,2 +1,13 @@ +[build_sphinx] +source-dir = doc/en/ +build-dir = doc/build +all_files = 1 + +[upload_sphinx] +upload-dir = doc/en/build/html + [bdist_wheel] -universal=1 +universal = 1 + +[devpi:upload] +formats = sdist.tgz,bdist_wheel @@ -48,7 +48,7 @@ def main(): description='virtualenv-based automation of test activities', long_description=open("README.rst").read(), url='http://tox.testrun.org/', - version='2.1.1', + version='2.1.2.dev1', license='http://opensource.org/licenses/MIT', platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'], author='holger krekel', diff --git a/tests/test_config.py b/tests/test_config.py index f0a8df0..16e1e57 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -88,6 +88,26 @@ class TestVenvConfig: 'dep1==1.5', 'dep2==2.1', 'dep3==3.0', 'dep4==4.0', ] + def test_force_dep_with_url(self, initproj): + initproj("example123-0.5", filedefs={ + 'tox.ini': ''' + [tox] + + [testenv] + deps= + dep1==1.0 + https://pypi.python.org/xyz/pkg1.tar.gz + ''' + }) + config = parseconfig( + ['--force-dep=dep1==1.5']) + assert config.option.force_dep == [ + 'dep1==1.5' + ] + assert [str(x) for x in config.envconfigs['python'].deps] == [ + 'dep1==1.5', 'https://pypi.python.org/xyz/pkg1.tar.gz' + ] + def test_is_same_dep(self): """ Ensure correct parseini._is_same_dep is working with a few samples. @@ -254,6 +274,28 @@ class TestIniParserAgainstCommandsKey: ["echo", "cmd", "1", "2", "3", "4", "cmd", "2"], ] + def test_command_env_substitution(self, newconfig): + """Ensure referenced {env:key:default} values are substituted correctly.""" + config = newconfig(""" + [testenv:py27] + setenv = + TEST=testvalue + commands = + ls {env:TEST} + """) + reader = SectionReader("testenv:py27", config._cfg) + x = reader.getargvlist("commands") + assert x == [ + "ls testvalue".split() + ] + assert x != [ + "ls {env:TEST}".split() + ] + y = reader.getargvlist("setenv") + assert y == [ + "TEST=testvalue".split() + ] + class TestIniParser: def test_getstring_single(self, tmpdir, newconfig): @@ -928,6 +970,18 @@ class TestConfigTestEnv: assert argv[7][0] == config.homedir.join(".tox", "distshare") assert argv[8][0] == conf.envlogdir + def test_substitution_notfound_issue246(tmpdir, newconfig): + config = newconfig(""" + [testenv:py27] + setenv = + FOO={envbindir} + BAR={envsitepackagesdir} + """) + conf = config.envconfigs['py27'] + env = conf.setenv + assert 'FOO' in env + assert 'BAR' in env + def test_substitution_positional(self, newconfig): inisource = """ [testenv:py27] diff --git a/tox/__init__.py b/tox/__init__.py index b2fed05..c4f8107 100644 --- a/tox/__init__.py +++ b/tox/__init__.py @@ -1,5 +1,5 @@ # -__version__ = '2.1.1' +__version__ = '2.1.2.dev1' from .hookspecs import hookspec, hookimpl # noqa diff --git a/tox/config.py b/tox/config.py index 640e21d..40c6e0a 100644 --- a/tox/config.py +++ b/tox/config.py @@ -141,7 +141,11 @@ class DepOption: same package, even if versions differ. """ dep1_name = pkg_resources.Requirement.parse(dep1).project_name - dep2_name = pkg_resources.Requirement.parse(dep2).project_name + try: + dep2_name = pkg_resources.Requirement.parse(dep2).project_name + except pkg_resources.RequirementParseError: + # we couldn't parse a version, probably a URL + return False return dep1_name == dep2_name @@ -320,6 +324,18 @@ def tox_addoption(parser): help="additional arguments available to command positional substitution") # add various core venv interpreter attributes + def basepython_default(testenv_config, value): + if value is None: + for f in testenv_config.factors: + if f in default_factors: + return default_factors[f] + return sys.executable + return str(value) + + parser.add_testenv_attribute( + name="basepython", type="string", default=None, postprocess=basepython_default, + help="executable name or path of interpreter used to create a " + "virtual test environment.") parser.add_testenv_attribute( name="envdir", type="path", default="{toxworkdir}/{envname}", @@ -453,19 +469,6 @@ def tox_addoption(parser): name="usedevelop", type="bool", postprocess=develop, default=False, help="install package in develop/editable mode") - def basepython_default(testenv_config, value): - if value is None: - for f in testenv_config.factors: - if f in default_factors: - return default_factors[f] - return sys.executable - return str(value) - - parser.add_testenv_attribute( - name="basepython", type="string", default=None, postprocess=basepython_default, - help="executable name or path of interpreter used to create a " - "virtual test environment.") - parser.add_testenv_attribute_obj(InstallcmdOption()) parser.add_testenv_attribute_obj(DepOption()) @@ -714,7 +717,7 @@ class parseini: if atype == "path": reader.addsubstitutions(**{env_attr.name: res}) - if env_attr.name == "install_command": + if env_attr.name == "envdir": reader.addsubstitutions(envbindir=vc.envbindir, envpython=vc.envpython, envsitepackagesdir=vc.envsitepackagesdir) return vc @@ -908,6 +911,7 @@ class SectionReader: return '\n'.join(filter(None, map(factor_line, lines))) def _replace_env(self, match): + env_list = self.getdict('setenv') match_value = match.group('substitution_value') if not match_value: raise tox.exception.ConfigError( @@ -922,11 +926,14 @@ class SectionReader: envkey = match_value if envkey not in os.environ and default is None: - raise tox.exception.ConfigError( - "substitution env:%r: unknown environment variable %r" % - (envkey, envkey)) - - return os.environ.get(envkey, default) + if envkey not in env_list and default is None: + raise tox.exception.ConfigError( + "substitution env:%r: unknown environment variable %r" % + (envkey, envkey)) + if envkey in os.environ: + return os.environ.get(envkey, default) + else: + return env_list.get(envkey, default) def _substitute_from_other_section(self, key): if key.startswith("[") and "]" in key: |