summaryrefslogtreecommitdiff
path: root/tests/template_tests/syntax_tests/test_spaceless.py
diff options
context:
space:
mode:
authorPreston Timmons <prestontimmons@gmail.com>2014-11-11 19:32:44 -0600
committerTim Graham <timograham@gmail.com>2014-12-02 19:18:35 -0500
commitb872134bfc14f6322bd1e4b0a08bf5bfd2c43a52 (patch)
treef82fc6be418adeb1e7ff36728f82008770066999 /tests/template_tests/syntax_tests/test_spaceless.py
parent4a4ad27712b44cebada1bdaebd082cf82df74610 (diff)
Fixed #23768 -- Rewrote template tests as unit tests.
Diffstat (limited to 'tests/template_tests/syntax_tests/test_spaceless.py')
-rw-r--r--tests/template_tests/syntax_tests/test_spaceless.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/template_tests/syntax_tests/test_spaceless.py b/tests/template_tests/syntax_tests/test_spaceless.py
new file mode 100644
index 0000000000..0c73a58bc5
--- /dev/null
+++ b/tests/template_tests/syntax_tests/test_spaceless.py
@@ -0,0 +1,38 @@
+from django.test import TestCase
+
+from .utils import render, setup
+
+
+class SpacelessTagTests(TestCase):
+
+ @setup({'spaceless01': "{% spaceless %} <b> <i> text </i> </b> {% endspaceless %}"})
+ def test_spaceless01(self):
+ output = render('spaceless01')
+ self.assertEqual(output, "<b><i> text </i></b>")
+
+ @setup({'spaceless02': "{% spaceless %} <b> \n <i> text </i> \n </b> {% endspaceless %}"})
+ def test_spaceless02(self):
+ output = render('spaceless02')
+ self.assertEqual(output, "<b><i> text </i></b>")
+
+ @setup({'spaceless03': "{% spaceless %}<b><i>text</i></b>{% endspaceless %}"})
+ def test_spaceless03(self):
+ output = render('spaceless03')
+ self.assertEqual(output, "<b><i>text</i></b>")
+
+ @setup({'spaceless04': "{% spaceless %}<b> <i>{{ text }}</i> </b>{% endspaceless %}"})
+ def test_spaceless04(self):
+ output = render('spaceless04', {'text': 'This & that'})
+ self.assertEqual(output, "<b><i>This &amp; that</i></b>")
+
+ @setup({'spaceless05': "{% autoescape off %}{% spaceless %}"
+ "<b> <i>{{ text }}</i> </b>{% endspaceless %}"
+ "{% endautoescape %}"})
+ def test_spaceless05(self):
+ output = render('spaceless05', {'text': 'This & that'})
+ self.assertEqual(output, "<b><i>This & that</i></b>")
+
+ @setup({'spaceless06': "{% spaceless %}<b> <i>{{ text|safe }}</i> </b>{% endspaceless %}"})
+ def test_spaceless06(self):
+ output = render('spaceless06', {'text': 'This & that'})
+ self.assertEqual(output, "<b><i>This & that</i></b>")