for Django templates

Saturday 17 January 2015This is over eight years old. Be careful.

A long experiment has come to fruition: support for Django templates. I’ve added plugin support to, and implemented a plugin for Django templates. If you want to try it in its current alpha state, read on.

The plugin itself is pip installable:

$ pip install django_coverage_plugin

To run it, add these settings to your .coveragerc:

# Makes it slower, won't be needed eventually
timid = True

plugins =

Then run your tests under It requires >= 4.0a2, so it may not work with other coverage-related tools such as test-runner coverage plugins, or The plugin works on Django >= 1.4, and Python 2 or 3.

You will see your templates listed in your coverage report alongside your Python modules. They have a .html extension but no directory, that’s still to be fixed.

The technique used to measure the coverage is the same that Dmitry Trofimov used in dtcov, but integrated into as a plugin, and made more performant. I’d love to see how well it works in a real production project. If you want to help me with it, feel free to drop me an email.

The plugin mechanism is designed to be generally useful for hooking into the collection and reporting phases of, specifically to support non-Python files. I’ve also got a plugin for Mako templates, but it needs some fixes from Mako. If you have non-Python files you’d like to support in, let’s talk.


Add a comment:

Ignore this:
Leave this empty:
Name is required. Either email or web are required. Email won't be displayed and I won't spam you. Your web site won't be indexed by search engines.
Don't put anything here:
Leave this empty:
Comment text is Markdown.