Tox: Combining basepython and an env with "py" in its name raises an exception

Created on 27 Sep 2018  路  3Comments  路  Source: tox-dev/tox

If a test environment has basepython set and has "py" in the environment name, e.g. py-test, tox fails with an exception. If I install tox<3.4 or add ignore_basepython_conflict to tox.ini the exception goes away.

This appears to have been caused by 1432cfbd19bb529e9a57cef21eb4923d77a8206c as a guard against non-matching regex was removed.

tox output

$ tox -e py-test
Traceback (most recent call last):
  File "/home/moggers/.virtualenvs/env/bin/tox", line 11, in <module>
    sys.exit(cmdline())
  File "/home/moggers/.virtualenvs/env/lib/python2.7/site-packages/tox/session.py", line 41, in cmdline
    main(args)
  File "/home/moggers/.virtualenvs/env/lib/python2.7/site-packages/tox/session.py", line 46, in main
    config = prepare(args)
  File "/home/moggers/.virtualenvs/env/lib/python2.7/site-packages/tox/session.py", line 28, in prepare
    config = parseconfig(args)
  File "/home/moggers/.virtualenvs/env/lib/python2.7/site-packages/tox/config.py", line 232, in parseconfig
    ParseIni(config, config_file, content)
  File "/home/moggers/.virtualenvs/env/lib/python2.7/site-packages/tox/config.py", line 1060, in __init__
    config.envconfigs[name] = self.make_envconfig(name, section, reader._subs, config)
  File "/home/moggers/.virtualenvs/env/lib/python2.7/site-packages/tox/config.py", line 1133, in make_envconfig
    res = env_attr.postprocess(testenv_config=tc, value=res)
  File "/home/moggers/.virtualenvs/env/lib/python2.7/site-packages/tox/config.py", line 559, in basepython_default
    implied_version = tox.PYTHON.PY_FACTORS_RE.match(factor).group(2)
AttributeError: 'NoneType' object has no attribute 'group'

tox.ini:

[tox]
skipsdist=true
envlist=
    my-test
    py-test

[testenv]
whitelist_externals=ls
commands=ls
basepython=python

pip list:

$ pip list
Package    Version
---------- -------
pip        18.0   
pluggy     0.7.1  
py         1.6.0  
setuptools 40.4.3 
six        1.11.0 
toml       0.9.6  
tox        3.4.0  
virtualenv 16.0.0 
wheel      0.31.1 
minor wanted

Most helpful comment

Will try to fix this, however note in general we don't recommend to name environments as py- unless it signals that python basepython is to be used. You can use the underscore instead of the dash if you still want to name your environments with a py section.

All 3 comments

I have the same problem.

Will try to fix this, however note in general we don't recommend to name environments as py- unless it signals that python basepython is to be used. You can use the underscore instead of the dash if you still want to name your environments with a py section.

I believe this was fixed in v3.8.0
I cant quickly spot which of these commits fixed it.

Was this page helpful?
0 / 5 - 0 ratings