Skip to content

Instantly share code, notes, and snippets.

@luzfcb
Last active August 29, 2015 14:06
Show Gist options
  • Save luzfcb/4669e7c77c4838388963 to your computer and use it in GitHub Desktop.
Save luzfcb/4669e7c77c4838388963 to your computer and use it in GitHub Desktop.

Running the Django tests with Tox

tox.ini goes into Django's root folder. test_*.py to the tests/ directory.

Install tox and run tox -e $python-$db. For instance, to run the tests on python 2.7 and sqlite:

tox -e py27-sqlite

You can also pass the app labels to test. To run the wsgi tests:

tox -e py27-sqlite -- wsgi
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'django_default',
'USER': 'postgres',
},
'other': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'django_other',
'USER': 'postgres',
}
}
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3'
},
'other': {
'ENGINE': 'django.db.backends.sqlite3',
}
}
[tox]
envlist =
py27-sqlite, py26-sqlite, py25-sqlite,
py27-postgres, py26-postgres, py25-postgres,
[testenv:py25-sqlite]
basepython = python2.5
commands = python tests/runtests.py --settings=test_sqlite {posargs:}
[testenv:py26-sqlite]
basepython = python2.6
commands = python tests/runtests.py --settings=test_sqlite {posargs:}
[testenv:py27-sqlite]
basepython = python2.7
commands = python tests/runtests.py --settings=test_sqlite {posargs:}
[testenv:py25-postgres]
basepython = python2.5
commands = python tests/runtests.py --settings=test_postgres {posargs:}
deps =
psycopg2==2.4.2
[testenv:py26-postgres]
basepython = python2.6
commands = python tests/runtests.py --settings=test_postgres {posargs:}
deps =
psycopg2==2.4.2
[testenv:py27-postgres]
basepython = python2.7
commands = python tests/runtests.py --settings=test_postgres {posargs:}
deps =
psycopg2==2.4.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment