django/tests/template_tests/syntax_tests/test_verbatim.py

40 lines
1.6 KiB
Python

from django.template.base import TemplateSyntaxError
from django.template.loader import get_template
from django.test import SimpleTestCase
from .utils import render, setup
class VerbatimTagTests(SimpleTestCase):
@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')