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

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Jamie Strandboge
  • Date: 2010-10-12 11:34:35 UTC
  • mfrom: (1.2.7 upstream)
  • mto: This revision was merged to the branch mainline in revision 30.
  • Revision ID: james.westby@ubuntu.com-20101012113435-9lnsrh0i3mxozbt0
Tags: upstream-1.2.3
ImportĀ upstreamĀ versionĀ 1.2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
506
506
            'basic-syntax28': ("{{ a.b }}", {'a': SilentGetItemClass()}, ('', 'INVALID')),
507
507
            'basic-syntax29': ("{{ a.b }}", {'a': SilentAttrClass()}, ('', 'INVALID')),
508
508
 
 
509
            # Something that starts like a number but has an extra lookup works as a lookup. 
 
510
            'basic-syntax30': ("{{ 1.2.3 }}", {"1": {"2": {"3": "d"}}}, "d"), 
 
511
            'basic-syntax31': ("{{ 1.2.3 }}", {"1": {"2": ("a", "b", "c", "d")}}, "d"), 
 
512
            'basic-syntax32': ("{{ 1.2.3 }}", {"1": (("x", "x", "x", "x"), ("y", "y", "y", "y"), ("a", "b", "c", "d"))}, "d"), 
 
513
            'basic-syntax33': ("{{ 1.2.3 }}", {"1": ("xxxx", "yyyy", "abcd")}, "d"), 
 
514
            'basic-syntax34': ("{{ 1.2.3 }}", {"1": ({"x": "x"}, {"y": "y"}, {"z": "z", "3": "d"})}, "d"), 
 
515
            
 
516
            # Numbers are numbers even if their digits are in the context. 
 
517
            'basic-syntax35': ("{{ 1 }}", {"1": "abc"}, "1"), 
 
518
            'basic-syntax36': ("{{ 1.2 }}", {"1": "abc"}, "1.2"), 
 
519
 
509
520
            # List-index syntax allows a template to access a certain item of a subscriptable object.
510
521
            'list-index01': ("{{ var.1 }}", {"var": ["first item", "second item"]}, "second item"),
511
522
 
592
603
 
593
604
            #filters should accept empty string constants
594
605
            'filter-syntax20': ('{{ ""|default_if_none:"was none" }}', {}, ""),
595
 
 
 
606
            
596
607
            ### COMMENT SYNTAX ########################################################
597
608
            'comment-syntax01': ("{# this is hidden #}hello", {}, "hello"),
598
609
            'comment-syntax02': ("{# this is hidden #}hello{# foo #}", {}, "hello"),
690
701
            'for-tag-unpack11': ("{% for x,y,z in items %}{{ x }}:{{ y }},{{ z }}/{% endfor %}", {"items": (('one', 1), ('two', 2))}, ("one:1,/two:2,/", "one:1,INVALID/two:2,INVALID/")),
691
702
            'for-tag-unpack12': ("{% for x,y,z in items %}{{ x }}:{{ y }},{{ z }}/{% endfor %}", {"items": (('one', 1, 'carrot'), ('two', 2))}, ("one:1,carrot/two:2,/", "one:1,carrot/two:2,INVALID/")),
692
703
            'for-tag-unpack13': ("{% for x,y,z in items %}{{ x }}:{{ y }},{{ z }}/{% endfor %}", {"items": (('one', 1, 'carrot'), ('two', 2, 'cheese'))}, ("one:1,carrot/two:2,cheese/", "one:1,carrot/two:2,cheese/")),
 
704
            'for-tag-unpack14': ("{% for x,y in items %}{{ x }}:{{ y }}/{% endfor %}", {"items": (1, 2)}, (":/:/", "INVALID:INVALID/INVALID:INVALID/")),
693
705
            'for-tag-empty01': ("{% for val in values %}{{ val }}{% empty %}empty text{% endfor %}", {"values": [1, 2, 3]}, "123"),
694
706
            'for-tag-empty02': ("{% for val in values %}{{ val }}{% empty %}values array empty{% endfor %}", {"values": []}, "values array empty"),
695
707
            'for-tag-empty03': ("{% for val in values %}{{ val }}{% empty %}values array not found{% endfor %}", {}, "values array not found"),
1285
1297
 
1286
1298
            # Regression test for #11270.
1287
1299
            'cache17': ('{% load cache %}{% cache 10 long_cache_key poem %}Some Content{% endcache %}', {'poem': 'Oh freddled gruntbuggly/Thy micturations are to me/As plurdled gabbleblotchits/On a lurgid bee/That mordiously hath bitled out/Its earted jurtles/Into a rancid festering/Or else I shall rend thee in the gobberwarts with my blurglecruncheon/See if I dont.'}, 'Some Content'),
1288
 
 
 
1300
                                    
 
1301
            
1289
1302
            ### AUTOESCAPE TAG ##############################################
1290
1303
            'autoescape-tag01': ("{% autoescape off %}hello{% endautoescape %}", {}, "hello"),
1291
1304
            'autoescape-tag02': ("{% autoescape off %}{{ first }}{% endautoescape %}", {"first": "<b>hello</b>"}, "<b>hello</b>"),
1314
1327
            # implementation details (fortunately, the (no)autoescape block
1315
1328
            # tags can be used in those cases)
1316
1329
            'autoescape-filtertag01': ("{{ first }}{% filter safe %}{{ first }} x<y{% endfilter %}", {"first": "<a>"}, template.TemplateSyntaxError),
 
1330
        
 
1331
            # ifqeual compares unescaped vales.
 
1332
            'autoescape-ifequal01': ('{% ifequal var "this & that" %}yes{% endifequal %}', { "var": "this & that" }, "yes" ), 
 
1333
            
 
1334
            # Arguments to filters are 'safe' and manipulate their input unescaped. 
 
1335
            'autoescape-filters01': ('{{ var|cut:"&" }}', { "var": "this & that" }, "this  that" ), 
 
1336
            'autoescape-filters02': ('{{ var|join:" & \" }}', { "var": ("Tom", "Dick", "Harry") }, "Tom & Dick & Harry" ), 
 
1337
            
 
1338
            # Literal strings are safe. 
 
1339
            'autoescape-literals01': ('{{ "this & that" }}',{}, "this & that" ), 
 
1340
            
 
1341
            # Iterating over strings outputs safe characters. 
 
1342
            'autoescape-stringiterations01': ('{% for l in var %}{{ l }},{% endfor %}', {'var': 'K&R'}, "K,&amp;,R," ), 
 
1343
            
 
1344
            # Escape requirement survives lookup. 
 
1345
            'autoescape-lookup01': ('{{ var.key }}', { "var": {"key": "this & that" }}, "this &amp; that" ), 
 
1346
                    
1317
1347
        }
1318
1348
 
1319
1349