/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
- from django.template.loader import get_template_from_string
- from django.template import VariableNode
- from django.utils.unittest import TestCase
- class NodelistTest(TestCase):
- def test_for(self):
- source = '{% for i in 1 %}{{ a }}{% endfor %}'
- template = get_template_from_string(source)
- vars = template.nodelist.get_nodes_by_type(VariableNode)
- self.assertEqual(len(vars), 1)
- def test_if(self):
- source = '{% if x %}{{ a }}{% endif %}'
- template = get_template_from_string(source)
- vars = template.nodelist.get_nodes_by_type(VariableNode)
- self.assertEqual(len(vars), 1)
- def test_ifequal(self):
- source = '{% ifequal x y %}{{ a }}{% endifequal %}'
- template = get_template_from_string(source)
- vars = template.nodelist.get_nodes_by_type(VariableNode)
- self.assertEqual(len(vars), 1)
- def test_ifchanged(self):
- source = '{% ifchanged x %}{{ a }}{% endifchanged %}'
- template = get_template_from_string(source)
- vars = template.nodelist.get_nodes_by_type(VariableNode)
- self.assertEqual(len(vars), 1)