Today I was adding tox and Travis-CI support to a Django project, and I ran into a problem: our project doesn’t have a setup.py
. Of course I could have added one, but since by convention we don’t package our Django projects (Django applications are a different story) – instead we use virtualenv and pip requirements files – I wanted to see if I could make tox work without changing our project.
Turns out it is quite easy: just add the following three directives to your tox.ini
.
In your [tox]
section tell tox not to run setup.py
:
skipsdist = True
In your [testenv]
section make tox install your requirements (see here for more details):
deps = -r{toxinidir}/dev-requirements.txt
Finally, also in your [testenv]
section, tell tox how to run your tests:
commands = python manage.py test
Now you can run tox
, and your tests should run!
For reference, here is a the complete (albeit minimal) tox.ini
file I used:
[tox] envlist = py27 skipsdist = True [testenv] deps = -r{toxinidir}/dev-requirements.txt setenv = PYTHONPATH = {toxinidir}:{toxinidir} commands = python manage.py test