[TIP] Django template coverage measurement

Ned Batchelder ned at nedbatchelder.com
Fri Jan 16 08:21:57 PST 2015

Randy, what I'm hoping is that the plugin feature is enough that other 
people can support their language of choice by writing plugins.  
Ideally, the Jinja project would provide the coverage.py plugin, and 
support it.  But yes, I would love to be able to coverage-measure Jinja 


On 1/16/15 11:08 AM, Randy Syring wrote:
> Hi Ned,
> Very nice!  If this works, will Jinja templates be something you would 
> look to support as well?
> *Randy Syring*
> Husband | Father | Redeemed Sinner
> /"For what does it profit a man to gain the whole world
> and forfeit his soul?" (Mark 8:36 ESV)/
> On 01/16/2015 10:46 AM, Ned Batchelder wrote:
>> 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.
>> _______________________________________________
>> testing-in-python mailing list
>> testing-in-python at lists.idyll.org
>> http://lists.idyll.org/listinfo/testing-in-python

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20150116/1d80970e/attachment.htm>

More information about the testing-in-python mailing list