Skip to main content

Django template coverage.py plugin

Project description

A coverage.py plugin to measure the coverage of Django templates.

Supported Python versions are 2.7 and 3.4. Supported Django versions are 1.4 through 1.8.

The plugin itself is pip installable:

$ pip install django_coverage_plugin

To run it, add this setting to your .coveragerc:

[run]
plugins =
    django_coverage_plugin

Then run your tests under coverage.py. It requires the latest coverage.py, so it may not work with other coverage-related tools such as test-runner coverage plugins, or coveralls.io.

You will see your templates listed in your coverage report alongside your Python modules.

If you get a django.core.exceptions.ImproperlyConfigured error, you need to set the DJANGO_SETTINGS_MODULE environment variable.

Configuration

The Django template plugin uses some existing settings from your .coveragerc file. The source=, include=, and omit= options control what template files are included in the report.

Caveats

Files included by the {% ssi %} tag are not included in the coverage measurements.

Coverage can’t tell whether a {% blocktrans %} tag used the singular or plural text, so both are marked as used if the tag is used.

What the? How?

The technique used to measure the coverage is the same that Dmitry Trofimov used in dtcov, but integrated into coverage.py 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 coverage.py plugin mechanism is designed to be generally useful for hooking into the collection and reporting phases of coverage.py, specifically to support non-Python files. If you have non-Python files you’d like to support in coverage.py, let’s talk.

Tests

To run the tests:

$ pip install -r requirements.txt
$ tox

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_coverage_plugin-0.5.tar.gz (4.9 kB view details)

Uploaded Source

File details

Details for the file django_coverage_plugin-0.5.tar.gz.

File metadata

File hashes

Hashes for django_coverage_plugin-0.5.tar.gz
Algorithm Hash digest
SHA256 b627c7eafd7734168548e55a8b68a93112fd2c2949b072a929f1052c689ac5d3
MD5 556fe5b06e3e20e9bddd692a9ce5b26f
BLAKE2b-256 f414702b4a0fac05da68db5cd5c3ceec076ed131db812a6513ec52ff7c7c6bbc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page