summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2016-02-15 15:15:07 -0500
committerNed Batchelder <ned@nedbatchelder.com>2016-02-15 15:15:07 -0500
commit4f83c4c7eb883769ecdbd407502d04bf0825cd0e (patch)
tree3b6adb9ae37b6fd12ba51fe28eeecc4c20958f6d /tests
parent1f0e50cdf60d38aa73e9eac8d3fdaf71061749ff (diff)
downloadpython-coveragepy-4f83c4c7eb883769ecdbd407502d04bf0825cd0e.tar.gz
Templite can now collapse whitespace after tags
Diffstat (limited to 'tests')
-rw-r--r--tests/test_templite.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/test_templite.py b/tests/test_templite.py
index 2f9b2db..1df942e 100644
--- a/tests/test_templite.py
+++ b/tests/test_templite.py
@@ -33,6 +33,7 @@ class TempliteTest(CoverageTest):
Result defaults to None so we can shorten the calls where we expect
an exception and never get to the result comparison.
+
"""
actual = Templite(text).render(ctx or {})
# If result is None, then an exception should have prevented us getting
@@ -44,6 +45,7 @@ class TempliteTest(CoverageTest):
"""Assert that a `TempliteSyntaxError` will happen.
A context manager, and the message should be `msg`.
+
"""
pat = "^" + re.escape(msg) + "$"
return self.assertRaisesRegex(TempliteSyntaxError, pat)
@@ -238,6 +240,26 @@ class TempliteTest(CoverageTest):
"@a0b0c0a1b1c1a2b2c2!"
)
+ def test_whitespace_handling(self):
+ self.try_render(
+ "@{% for n in nums %}\n"
+ " {% for a in abc %}{{a}}{{n}}{% endfor %}\n"
+ "{% endfor %}!\n",
+ {'nums': [0, 1, 2], 'abc': ['a', 'b', 'c']},
+ "@\n a0b0c0\n\n a1b1c1\n\n a2b2c2\n!\n"
+ )
+ self.try_render(
+ "@{% for n in nums -%}\n"
+ " {% for a in abc -%}\n"
+ " {# this disappears completely -#}\n"
+ " {{a -}}\n"
+ " {{n -}}\n"
+ " {% endfor %}\n"
+ "{% endfor %}!\n",
+ {'nums': [0, 1, 2], 'abc': ['a', 'b', 'c']},
+ "@a0b0c0\na1b1c1\na2b2c2\n!\n"
+ )
+
def test_non_ascii(self):
self.try_render(
u"{{where}} ollǝɥ",