Skip to content

Commit 843a60b

Browse files
committed
test: add defensive checks for same kind nested blocks, whitespace around comment
1 parent a086c59 commit 843a60b

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

tests/test_pragma.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,30 @@ def test_pragma_with_nested_blocks(self):
5959
)
6060
self.assert_analysis([1, 7])
6161

62+
def test_nested_if_blocks(self):
63+
"""Test that nested block of same type are handled."""
64+
self.make_template("""\
65+
Before
66+
{% if 1 %}{# pragma: no cover #}
67+
{% if 0 %}
68+
Not covered
69+
{% endif %}
70+
Also not covered, due to parent block.
71+
{% endif %}
72+
After
73+
""")
74+
self.run_django_coverage()
75+
self.assert_analysis([1, 8])
76+
77+
def test_whitespace_around_pragma(self):
78+
"""Test that whitespace characters are stripped."""
79+
self.make_template("""\
80+
Before
81+
{% load static %}{# pragma: no cover #}
82+
""")
83+
self.run_django_coverage()
84+
self.assert_analysis([1])
85+
6286
def test_custom_exclude_patterns(self):
6387
"""Test that coverage.py config for report:exclude_lines is used."""
6488
self.make_template("""\

0 commit comments

Comments
 (0)