Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Ignore lines in templates #70

Open
mschoettle opened this issue May 5, 2020 · 2 comments
Open

Ignore lines in templates #70

mschoettle opened this issue May 5, 2020 · 2 comments

Comments

@mschoettle
Copy link

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.

@nedbat
Copy link
Owner

nedbat commented May 6, 2020

The plugin is written to understand comment blocks and ignore them. Can you provide us with a reproducible test case?

@mschoettle
Copy link
Author

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.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants