mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Fixed #6510 -- Refactored the way child nodes are found in template nodes to avoid potential inconsistencies. Thanks to SmileyChris for the patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12654 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
30
tests/regressiontests/templates/nodelist.py
Normal file
30
tests/regressiontests/templates/nodelist.py
Normal file
@@ -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)
|
||||
Reference in New Issue
Block a user