How to Test Against Multiple Python Versions in Parallel
The answer is making use of pyenv and detox.
If you haven’t heard of pyenv yet, it’s worth
checking out. It makes it a snap to manage both different virtualenvs as well
as different versions of Python. You get the virtualenv extensions by installingpyenv-virtualenv and pyenv-virtualenvwrapper.
Installation
The simplest way to do this on OS X is to use brew:
brew install pyenv pyenv-virtualenv pyenv-virtualenvwrapper
Then you’ll want to install all the Pythons you want to test with that are in your tox.ini:
pyenv install 2.7.10 pyenv install 3.2.6 pyenv install 3.3.6 pyenv install 3.4.3 pyenv install 3.5.0
Setup
You’ll then want to set all these to be global versions:
pyenv global 2.7.10 3.2.6 3.3.6 3.4.3 3.5.0
At this point, exit your terminal and open up a new one and run:
pyenv versions
To make sure all the global ones are set properly.
Now, install detox globally (without being in a virtualenv):
pip install detox
Now in any project with a tox.ini with Python versions you have installed you
can simply run detox to run all tests in parallel without getting into a
certain environment. detox and tox will take care of creating environments
to run tests in and enter those environments, and run tests, all in a parallel.
Sample tox.ini
Here is an example of the tox.ini from pinax-stripe:
Happy testing!