diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2010-03-02 07:42:51 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2010-03-02 07:42:51 +0000 |
| commit | f034c79cbc4f1a235e53d4ec666885ab8e9af8d9 (patch) | |
| tree | 9d64966c0af403b76d796965afa00b2727e924a1 /tests/regressiontests/templates/nodelist.py | |
| parent | ecb56cecbddffe7f06e94a08d2d71713d85514e4 (diff) | |
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
Diffstat (limited to 'tests/regressiontests/templates/nodelist.py')
| -rw-r--r-- | tests/regressiontests/templates/nodelist.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/regressiontests/templates/nodelist.py b/tests/regressiontests/templates/nodelist.py new file mode 100644 index 0000000000..89fac97c66 --- /dev/null +++ b/tests/regressiontests/templates/nodelist.py @@ -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) |
