parts/django/tests/regressiontests/templates/nodelist.py
changeset 69 c6bca38c1cbf
equal deleted inserted replaced
68:5ff1fc726848 69:c6bca38c1cbf
       
     1 from unittest import TestCase
       
     2 from django.template.loader import get_template_from_string
       
     3 from django.template import VariableNode
       
     4 
       
     5 
       
     6 class 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)