parts/django/tests/regressiontests/templates/nodelist.py
changeset 69 c6bca38c1cbf
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/parts/django/tests/regressiontests/templates/nodelist.py	Sat Jan 08 11:20:57 2011 +0530
@@ -0,0 +1,30 @@
+from unittest import TestCase
+from django.template.loader import get_template_from_string
+from django.template import VariableNode
+
+
+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)