Testing in different environments

Tox is a tool for automate testing in Python. It does so by reading
a tox.ini file where we specify the environments we want to test, and it will create a brand new
virtual environment for that setup and run the test suite against it.
Let’s start by installing tox and add it to our requirements.txt file.

(django-foobar):~/django-foobar$ pip install tox
(django-foobar):~/django-foobar$ echo “tox” >> requirements.txt

Create a new file tox.ini in the projects working directory and paste the content below.

envlist =

deps =

deps =

commands =
python {toxinidir}/setup.py test

basepython = python2.7
deps =

basepython = python3.4
deps =

As you can see we have a [tox] block in which we defines a list of environments we want to test.
Next, we define some blocks for the different Django versions we want to test. The [testenv] block
defines the command we want to run, and finally we combine the [testenv] with the different version
blocks in order to fire up the test runner.