PageRenderTime 14ms CodeModel.GetById 2ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/tests/regressiontests/templates/nodelist.py

https://code.google.com/p/mango-py/
Python | 30 lines | 24 code | 6 blank | 0 comment | 0 complexity | 06958aa392db7d271756847654aad780 MD5 | raw file
 1from django.template.loader import get_template_from_string
 2from django.template import VariableNode
 3from django.utils.unittest import TestCase
 4
 5
 6class NodelistTest(TestCase):
 7
 8    def test_for(self):
 9        source = '{% for i in 1 %}{{ a }}{% endfor %}'
10        template = get_template_from_string(source)
11        vars = template.nodelist.get_nodes_by_type(VariableNode)
12        self.assertEqual(len(vars), 1)
13
14    def test_if(self):
15        source = '{% if x %}{{ a }}{% endif %}'
16        template = get_template_from_string(source)
17        vars = template.nodelist.get_nodes_by_type(VariableNode)
18        self.assertEqual(len(vars), 1)
19
20    def test_ifequal(self):
21        source = '{% ifequal x y %}{{ a }}{% endifequal %}'
22        template = get_template_from_string(source)
23        vars = template.nodelist.get_nodes_by_type(VariableNode)
24        self.assertEqual(len(vars), 1)
25
26    def test_ifchanged(self):
27        source = '{% ifchanged x %}{{ a }}{% endifchanged %}'
28        template = get_template_from_string(source)
29        vars = template.nodelist.get_nodes_by_type(VariableNode)
30        self.assertEqual(len(vars), 1)