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