|
1 | 1 | Django Template Coverage Plugin
|
2 | 2 | ===============================
|
3 | 3 |
|
4 |
| -A coverage.py plugin to measure the coverage of Django templates. |
| 4 | +A `coverage.py`_ plugin to measure the coverage of Django templates. |
5 | 5 |
|
6 |
| -Details of how to use it are in this `blog post`_. Real docs are TBD. |
| 6 | +Supported Python versions are 2.7 and 3.4. Supported Django versions are 1.4 |
| 7 | +through 1.8 alpha. |
7 | 8 |
|
8 |
| -.. _blog post: http://nedbatchelder.com/blog/201501/coveragepy_for_django_templates.html |
| 9 | +The plugin itself is pip installable:: |
9 | 10 |
|
| 11 | + $ pip install django_coverage_plugin |
10 | 12 |
|
11 |
| -To run the tests on Python 2.7:: |
| 13 | +To run it, add this setting to your .coveragerc:: |
12 | 14 |
|
13 |
| - $ pip install -r requirements.txt |
14 |
| - $ tox |
| 15 | + [run] |
| 16 | + plugins = |
| 17 | + django_coverage_plugin |
| 18 | + |
| 19 | +Then run your tests under coverage.py. It requires the latest coverage.py, so |
| 20 | +it may not work with other coverage-related tools such as test-runner coverage |
| 21 | +plugins, or coveralls.io. |
15 | 22 |
|
| 23 | +You will see your templates listed in your coverage report alongside your |
| 24 | +Python modules. |
16 | 25 |
|
17 |
| -Yet to be done |
| 26 | + |
| 27 | +What the? How? |
18 | 28 | --------------
|
19 | 29 |
|
20 |
| -- Plugins can provide data to "debug sys". |
| 30 | +The technique used to measure the coverage is the same that Dmitry Trofimov |
| 31 | +used in `dtcov`_, but integrated into coverage.py as a plugin, and made more |
| 32 | +performant. I'd love to see how well it works in a real production project. If |
| 33 | +you want to help me with it, feel free to drop me an email. |
| 34 | + |
| 35 | +The coverage.py plugin mechanism is designed to be generally useful for hooking |
| 36 | +into the collection and reporting phases of coverage.py, specifically to |
| 37 | +support non-Python files. I've also got a plugin for Mako templates, but it |
| 38 | +needs some fixes from Mako. If you have non-Python files you'd like to support |
| 39 | +in coverage.py, let's talk. |
21 | 40 |
|
22 |
| -- Specialize debug tracing? |
23 | 41 |
|
24 |
| -- Figure out the path to the template so they aren't just simple file names |
25 |
| - in the reports. |
| 42 | +Tests |
| 43 | +----- |
| 44 | + |
| 45 | +To run the tests:: |
| 46 | + |
| 47 | + $ pip install -r requirements.txt |
| 48 | + $ tox |
26 | 49 |
|
27 |
| -- How to find unexecuted templates? |
28 | 50 |
|
29 |
| -- Docs |
| 51 | +.. _coverage.py: http://nedbatchelder.com/code/coverage |
| 52 | +.. _dtcov: https://github.com/traff/dtcov |
0 commit comments