django_coverage_plugin
django_coverage_plugin copied to clipboard
Ignore lines in templates
Is it possible to exclude certain lines in templates?
For example:
{% comment "foo" %}
some commented out stuff
{% endcomment %}
This will show up in the report as missing lines.
I tried adding {# pragma: no cover #} but it did not work.
The plugin is written to understand comment blocks and ignore them. Can you provide us with a reproducible test case?
I have a template file containing the above block:
{% comment "foo" %}
some commented out stuff
{% endcomment %}
And a test function like this:
def test_foo(client):
response = client.get(reverse('app:foo'))
...
The relevant part of setup.cfg is as follows:
[coverage:run]
source = projectname
omit =
.*,
*tests*,
*migrations*,
branch = True
plugins =
django_coverage_plugin
Another reason why I asked is a {% block content %} definition in a base template which spans more than one line (i.e., the endblock is in a subsequent line. It's not going to be executed so I was wondering if there is a way to ignore them.