Now once you've installed and configured your Django project with py.test, let's add Coverage!
First install coverage like so:
$ pip install coverage==3.7.1
Then add a .coveragerc in the root of your project (next to manage.py):
# exclude tests
# exclude factories
pragma: no cover
# Don't complain about missing debug-only code:
# Don't complain if tests don't hit defensive assertion code:
# Don't complain if non-runnable code isn't run:
if __name__ == .__main__.:
directory = htmlcov
title = YourProject Coverage Report
Where yourproject should be replaced with the name of your project.
Now you can run the coverage like so:
$ coverage run --source . -m py.test && coverage html
The output will be generated in the directory you configured in .coveragerc (htmlcov by default).