Skip to main content

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

Supported Python versions: 2.7, 3.4, 3.5, 3.6, 3.7 and 3.8.

Supported Django versions: 1.8, 1.11, 2.0, 2.1, 2.2 and 3.0.

Supported coverage.py version 4.x or 5.x.

The plugin is pip installable:

$ pip install django_coverage_plugin

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

[run]
plugins =
    django_coverage_plugin

Then run your tests under coverage.py.

You will see your templates listed in your coverage report along with your Python modules. Please use coverage.py v4.4 or greater to allow the plugin to identify untested templates.

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

Coverage.py 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

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-1.8.0.tar.gz (11.9 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: django_coverage_plugin-1.8.0.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.6

File hashes

Hashes for django_coverage_plugin-1.8.0.tar.gz
Algorithm Hash digest
SHA256 d53cbf3828fd83d6b89ff7292c6805de5274e36411711692043e67bcde25ae0c
MD5 a37514930de26247512bc629b87d87dd
BLAKE2b-256 4fdea0feccac7b155cf12d118d22deb04d47ff4093ac2cc35a2021ee4a86187b

See more details on using hashes here.

Release history Release notifications | RSS feed

3.2.2

2 files

3.2.0

2 files

3.1.1

2 files

3.1.0

2 files

3.0.0

2 files

2.0.4

2 files

2.0.3

2 files

2.0.2

2 files

2.0.1

1 file

2.0.0

1 file

This release

1.8.0 This release

1 file

1.7.0

1 file

1.6.0

1 file

1.5.0

1 file

1.4.2

1 file

1.4.1

1 file

1.4

1 file

1.3.1

1 file

1.3

1 file

1.2.2

1 file

1.2.1

1 file

1.2

1 file

1.1

1 file

1.0

1 file

1.0b1

0.6

1 file

0.5

1 file

0.3.3

1 file

0.3.2

1 file

0.3.1

1 file

0.3

1 file

0.1

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page