You may want to have pytest
as test runner. Configuration example follows.
Sample pytest.ini
file:
[pytest]
norecursedirs=
*.egg
.git
.tox
.env
_sass
build
dist
migrations
fabfile
.tox
python_files =
test_*.py
tests.py
DJANGO_SETTINGS_MODULE=settings.dev
addopts=
--reuse-db
--nomigrations
--cov=your_app
--ignore=.tox
--ignore=fabfile
--ignore=scripts
--ignore=settings
--ignore=tmp
--cov-report=html
--cov-report=term
--cov-report=annotate
Sample runtests.py
file:
#!/usr/bin/env python
import os
import sys
import pytest
def main():
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings.dev")
return pytest.main()
if __name__ == '__main__':
sys.exit(main())
Sample requirements.txt
file:
pytest==3.0.2
pytest-django==2.9.1
pytest-cov==2.2.1
Run the tests:
./runtests.py
Note, that effect is achieved through reuse-db
and nomigrations
directives.