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