2014-11-12 09:32:44 +08:00
|
|
|
from django.template.base import TemplateSyntaxError
|
|
|
|
from django.template.loader import get_template
|
2014-12-04 04:36:17 +08:00
|
|
|
from django.test import SimpleTestCase
|
2014-11-12 09:32:44 +08:00
|
|
|
|
2014-12-04 10:21:11 +08:00
|
|
|
from ..utils import render, setup
|
2014-11-12 09:32:44 +08:00
|
|
|
|
|
|
|
|
2014-12-04 04:36:17 +08:00
|
|
|
class VerbatimTagTests(SimpleTestCase):
|
2014-11-12 09:32:44 +08:00
|
|
|
|
|
|
|
@setup({'verbatim-tag01': '{% verbatim %}{{bare }}{% endverbatim %}'})
|
|
|
|
def test_verbatim_tag01(self):
|
|
|
|
output = render('verbatim-tag01')
|
|
|
|
self.assertEqual(output, '{{bare }}')
|
|
|
|
|
|
|
|
@setup({'verbatim-tag02': '{% verbatim %}{% endif %}{% endverbatim %}'})
|
|
|
|
def test_verbatim_tag02(self):
|
|
|
|
output = render('verbatim-tag02')
|
|
|
|
self.assertEqual(output, '{% endif %}')
|
|
|
|
|
|
|
|
@setup({'verbatim-tag03': '{% verbatim %}It\'s the {% verbatim %} tag{% endverbatim %}'})
|
|
|
|
def test_verbatim_tag03(self):
|
|
|
|
output = render('verbatim-tag03')
|
|
|
|
self.assertEqual(output, 'It\'s the {% verbatim %} tag')
|
|
|
|
|
|
|
|
@setup({'verbatim-tag04': '{% verbatim %}{% verbatim %}{% endverbatim %}{% endverbatim %}'})
|
|
|
|
def test_verbatim_tag04(self):
|
|
|
|
with self.assertRaises(TemplateSyntaxError):
|
|
|
|
get_template('verbatim-tag04')
|
|
|
|
|
|
|
|
@setup({'verbatim-tag05': '{% verbatim %}{% endverbatim %}{% verbatim %}{% endverbatim %}'})
|
|
|
|
def test_verbatim_tag05(self):
|
|
|
|
output = render('verbatim-tag05')
|
|
|
|
self.assertEqual(output, '')
|
|
|
|
|
|
|
|
@setup({'verbatim-tag06': '{% verbatim special %}'
|
|
|
|
'Don\'t {% endverbatim %} just yet{% endverbatim special %}'})
|
|
|
|
def test_verbatim_tag06(self):
|
|
|
|
output = render('verbatim-tag06')
|
|
|
|
self.assertEqual(output, 'Don\'t {% endverbatim %} just yet')
|