from django.test import TestCase from .utils import render, setup class SpacelessTagTests(TestCase): @setup({'spaceless01': "{% spaceless %} text {% endspaceless %}"}) def test_spaceless01(self): output = render('spaceless01') self.assertEqual(output, " text ") @setup({'spaceless02': "{% spaceless %} \n text \n {% endspaceless %}"}) def test_spaceless02(self): output = render('spaceless02') self.assertEqual(output, " text ") @setup({'spaceless03': "{% spaceless %}text{% endspaceless %}"}) def test_spaceless03(self): output = render('spaceless03') self.assertEqual(output, "text") @setup({'spaceless04': "{% spaceless %} {{ text }} {% endspaceless %}"}) def test_spaceless04(self): output = render('spaceless04', {'text': 'This & that'}) self.assertEqual(output, "This & that") @setup({'spaceless05': "{% autoescape off %}{% spaceless %}" " {{ text }} {% endspaceless %}" "{% endautoescape %}"}) def test_spaceless05(self): output = render('spaceless05', {'text': 'This & that'}) self.assertEqual(output, "This & that") @setup({'spaceless06': "{% spaceless %} {{ text|safe }} {% endspaceless %}"}) def test_spaceless06(self): output = render('spaceless06', {'text': 'This & that'}) self.assertEqual(output, "This & that")