Python Tox

2015/02/28 Python

Tox is a very good tool to run unit test for Python project, it is used widely in OpenStack.

No module named xxx

Sometimes, after you refresh the repository, then rerun the tox command, you may failed to run tests for “No module named xxx”. This may caused new introduced requirements and you environment has been created before that, then your environment is outdated. You can use tox -r -epy27 to force recreate the environment, or if you want to save your time (especially when you are behind a proxy), you can run . .tox/py27/bin/activate && pip install -U -r requirements.txt -r test-requirements.txt; deactivate

certificate verify failed

distutils.errors.DistutilsError: Download error for https://pypi.python.org/packages/2.7/p/pyasn1/pyasn1-0.1.7-py2.7.egg#md5=15f079cabee01402bf86ca8b83356469: [Errno 1] _ssl.c:510: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

Tox may fail to create environment if you are behind a proxy and pypi.python.org is killed by that proxy. Usually you can use a mirror instead, but sometimes the dependency is messed and may still fetch package from pypi.python.org which you cannot control. I experienced this when I run tox -egabbi in Ceilometer project. The trick is that you can remove all the dependency in tox.ini [testenv:gabbi] section by set “dep =”, then run tox -r -egabbi to just create an “empty” environment, after it succeed, run . .tox/gabbi/bin/activate && pip install -U -r requirements.txt -r test-requirements.txt; deactivate to install dependencies, finally recover the tox.ini file and enjoy it.

License: (CC 3.0) BY-NC-SA

Search

    Table of Contents