Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
path: root/tests/template_tests/syntax_tests/test_template_tag.py
blob: e868c9f21a6808b6b2232f578acce73f3f49f406 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
from django.template import TemplateSyntaxError
from django.test import SimpleTestCase

from ..utils import setup


class TemplateTagTests(SimpleTestCase):

    @setup({'templatetag01': '{% templatetag openblock %}'})
    def test_templatetag01(self):
        output = self.engine.render_to_string('templatetag01')
        self.assertEqual(output, '{%')

    @setup({'templatetag02': '{% templatetag closeblock %}'})
    def test_templatetag02(self):
        output = self.engine.render_to_string('templatetag02')
        self.assertEqual(output, '%}')

    @setup({'templatetag03': '{% templatetag openvariable %}'})
    def test_templatetag03(self):
        output = self.engine.render_to_string('templatetag03')
        self.assertEqual(output, '{{')

    @setup({'templatetag04': '{% templatetag closevariable %}'})
    def test_templatetag04(self):
        output = self.engine.render_to_string('templatetag04')
        self.assertEqual(output, '}}')

    @setup({'templatetag05': '{% templatetag %}'})
    def test_templatetag05(self):
        with self.assertRaises(TemplateSyntaxError):
            self.engine.get_template('templatetag05')

    @setup({'templatetag06': '{% templatetag foo %}'})
    def test_templatetag06(self):
        with self.assertRaises(TemplateSyntaxError):
            self.engine.get_template('templatetag06')

    @setup({'templatetag07': '{% templatetag openbrace %}'})
    def test_templatetag07(self):
        output = self.engine.render_to_string('templatetag07')
        self.assertEqual(output, '{')

    @setup({'templatetag08': '{% templatetag closebrace %}'})
    def test_templatetag08(self):
        output = self.engine.render_to_string('templatetag08')
        self.assertEqual(output, '}')

    @setup({'templatetag09': '{% templatetag openbrace %}{% templatetag openbrace %}'})
    def test_templatetag09(self):
        output = self.engine.render_to_string('templatetag09')
        self.assertEqual(output, '{{')

    @setup({'templatetag10': '{% templatetag closebrace %}{% templatetag closebrace %}'})
    def test_templatetag10(self):
        output = self.engine.render_to_string('templatetag10')
        self.assertEqual(output, '}}')

    @setup({'templatetag11': '{% templatetag opencomment %}'})
    def test_templatetag11(self):
        output = self.engine.render_to_string('templatetag11')
        self.assertEqual(output, '{#')

    @setup({'templatetag12': '{% templatetag closecomment %}'})
    def test_templatetag12(self):
        output = self.engine.render_to_string('templatetag12')
        self.assertEqual(output, '#}')