2014-12-07 08:43:10 +00:00
|
|
|
from django.template import TemplateSyntaxError
|
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 VerbatimTagTests(SimpleTestCase):
|
2014-11-12 01:32:44 +00:00
|
|
|
@setup({"verbatim-tag01": "{% verbatim %}{{bare }}{% endverbatim %}"})
|
|
|
|
def test_verbatim_tag01(self):
|
2014-12-07 08:43:10 +00:00
|
|
|
output = self.engine.render_to_string("verbatim-tag01")
|
2014-11-12 01:32:44 +00:00
|
|
|
self.assertEqual(output, "{{bare }}")
|
|
|
|
|
|
|
|
@setup({"verbatim-tag02": "{% verbatim %}{% endif %}{% endverbatim %}"})
|
|
|
|
def test_verbatim_tag02(self):
|
2014-12-07 08:43:10 +00:00
|
|
|
output = self.engine.render_to_string("verbatim-tag02")
|
2014-11-12 01:32:44 +00:00
|
|
|
self.assertEqual(output, "{% endif %}")
|
|
|
|
|
|
|
|
@setup(
|
|
|
|
{"verbatim-tag03": "{% verbatim %}It's the {% verbatim %} tag{% endverbatim %}"}
|
|
|
|
)
|
|
|
|
def test_verbatim_tag03(self):
|
2014-12-07 08:43:10 +00:00
|
|
|
output = self.engine.render_to_string("verbatim-tag03")
|
2014-11-12 01:32:44 +00:00
|
|
|
self.assertEqual(output, "It's the {% verbatim %} tag")
|
2022-02-03 19:24:19 +00:00
|
|
|
|
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
|
|
|
"verbatim-tag04": (
|
|
|
|
"{% verbatim %}{% verbatim %}{% endverbatim %}{% endverbatim %}"
|
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_verbatim_tag04(self):
|
|
|
|
with self.assertRaises(TemplateSyntaxError):
|
2014-12-07 08:43:10 +00:00
|
|
|
self.engine.get_template("verbatim-tag04")
|
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
|
|
|
"verbatim-tag05": (
|
|
|
|
"{% verbatim %}{% endverbatim %}{% verbatim %}{% endverbatim %}"
|
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_verbatim_tag05(self):
|
2014-12-07 08:43:10 +00:00
|
|
|
output = self.engine.render_to_string("verbatim-tag05")
|
2014-11-12 01:32:44 +00:00
|
|
|
self.assertEqual(output, "")
|
2022-02-03 19:24:19 +00:00
|
|
|
|
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
|
|
|
"verbatim-tag06": "{% verbatim special %}"
|
|
|
|
"Don't {% endverbatim %} just yet{% endverbatim special %}"
|
2022-02-03 19:24:19 +00:00
|
|
|
}
|
2014-11-12 01:32:44 +00:00
|
|
|
)
|
|
|
|
def test_verbatim_tag06(self):
|
2014-12-07 08:43:10 +00:00
|
|
|
output = self.engine.render_to_string("verbatim-tag06")
|
2014-11-12 01:32:44 +00:00
|
|
|
self.assertEqual(output, "Don't {% endverbatim %} just yet")
|