~ubuntu-branches/ubuntu/quantal/python-django/quantal-security

« back to all changes in this revision

Viewing changes to tests/regressiontests/templates/nodelist.py

  • Committer: Bazaar Package Importer
  • Author(s): Chris Lamb
  • Date: 2010-05-21 07:52:55 UTC
  • mfrom: (1.3.6 upstream)
  • mto: This revision was merged to the branch mainline in revision 28.
  • Revision ID: james.westby@ubuntu.com-20100521075255-ii78v1dyfmyu3uzx
Tags: upstream-1.2
ImportĀ upstreamĀ versionĀ 1.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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)