[TIP] Django template coverage measurement
Ned Batchelder
ned at nedbatchelder.com
Fri Jan 16 07:46:24 PST 2015
Hi,
I've added support to coverage.py for plugins to support non-Python
files, and I've written a plugin to measure Django templates. I'm
looking for people interested in trying it out in its current alpha-state.
If you'd like to try it, the plugin itself is pip installable: pip
install django_coverage_plugin . To run it, add these settings to your
.coveragerc:
[run]
# won't be needed eventually
timid = True
plugins =
django_coverage_plugin
Then run your tests under coverage as you normally would. It requires
coverage.py>=4.0a2, so it may not work with other coverage-related tools
if you have them, such as coveralls.io. 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 coverage.py, 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, feel free to reply offlist if
it's more appropriate.
BTW, 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. 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 add coverage support for, let's talk.
Thanks,
--Ned.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20150116/0e735a5b/attachment.html>
More information about the testing-in-python
mailing list