2014-12-03 21:36:17 +01:00
|
|
|
from django.test import SimpleTestCase
|
2014-11-12 02:32:44 +01:00
|
|
|
|
2014-12-07 09:43:10 +01:00
|
|
|
from ..utils import setup
|
2014-11-12 02:32:44 +01:00
|
|
|
|
|
|
|
|
2014-12-03 21:36:17 +01:00
|
|
|
class SpacelessTagTests(SimpleTestCase):
|
2014-11-12 02:32:44 +01:00
|
|
|
|
|
|
|
@setup({'spaceless01': "{% spaceless %} <b> <i> text </i> </b> {% endspaceless %}"})
|
|
|
|
def test_spaceless01(self):
|
2014-12-07 09:43:10 +01:00
|
|
|
output = self.engine.render_to_string('spaceless01')
|
2014-11-12 02:32:44 +01:00
|
|
|
self.assertEqual(output, "<b><i> text </i></b>")
|
|
|
|
|
|
|
|
@setup({'spaceless02': "{% spaceless %} <b> \n <i> text </i> \n </b> {% endspaceless %}"})
|
|
|
|
def test_spaceless02(self):
|
2014-12-07 09:43:10 +01:00
|
|
|
output = self.engine.render_to_string('spaceless02')
|
2014-11-12 02:32:44 +01:00
|
|
|
self.assertEqual(output, "<b><i> text </i></b>")
|
|
|
|
|
|
|
|
@setup({'spaceless03': "{% spaceless %}<b><i>text</i></b>{% endspaceless %}"})
|
|
|
|
def test_spaceless03(self):
|
2014-12-07 09:43:10 +01:00
|
|
|
output = self.engine.render_to_string('spaceless03')
|
2014-11-12 02:32:44 +01:00
|
|
|
self.assertEqual(output, "<b><i>text</i></b>")
|
|
|
|
|
|
|
|
@setup({'spaceless04': "{% spaceless %}<b> <i>{{ text }}</i> </b>{% endspaceless %}"})
|
|
|
|
def test_spaceless04(self):
|
2014-12-07 09:43:10 +01:00
|
|
|
output = self.engine.render_to_string('spaceless04', {'text': 'This & that'})
|
2014-11-12 02:32:44 +01:00
|
|
|
self.assertEqual(output, "<b><i>This & that</i></b>")
|
|
|
|
|
|
|
|
@setup({'spaceless05': "{% autoescape off %}{% spaceless %}"
|
|
|
|
"<b> <i>{{ text }}</i> </b>{% endspaceless %}"
|
|
|
|
"{% endautoescape %}"})
|
|
|
|
def test_spaceless05(self):
|
2014-12-07 09:43:10 +01:00
|
|
|
output = self.engine.render_to_string('spaceless05', {'text': 'This & that'})
|
2014-11-12 02:32:44 +01:00
|
|
|
self.assertEqual(output, "<b><i>This & that</i></b>")
|
|
|
|
|
|
|
|
@setup({'spaceless06': "{% spaceless %}<b> <i>{{ text|safe }}</i> </b>{% endspaceless %}"})
|
|
|
|
def test_spaceless06(self):
|
2014-12-07 09:43:10 +01:00
|
|
|
output = self.engine.render_to_string('spaceless06', {'text': 'This & that'})
|
2014-11-12 02:32:44 +01:00
|
|
|
self.assertEqual(output, "<b><i>This & that</i></b>")
|