Ticket #11376: escapetests.diff

File escapetests.diff, 1.7 KB (added by Stephen Kelly, 15 years ago)
  • tests.py

     
    428438            #filters should accept empty string constants
    429439            'filter-syntax20': ('{{ ""|default_if_none:"was none" }}', {}, ""),
    430440
     441            # Html escaping is not to be confused with for example url escaping.
     442            'escape01': ('{{ var }}',{ "var": "< > & \" \' # = % $" }, "&lt; &gt; &amp; &quot; &#39; # = % $" ),
     443            'escape02': ('{{ var }}',{ "var": "this & that" }, "this &amp; that" ),
     444
     445            # Strings are compared unescaped.
     446            'escape03': ('{% ifequal var \"this & that\" %}yes{% endifequal %}',{ "var": "this & that" }, "yes" ),
     447
     448            # Arguments to filters are 'safe' and manipulate their input unescaped.
     449            'escape04': ('{{ var|cut:\"&\" }}',{ "var": "this & that" }, "this  that" ),
     450            'escape05': ('{{ varList|join:\" & \" }}',{ "var": ("Tom", "Dick", "Harry") }, "Tom & Dick & Harry" ),
     451
     452            # Literal strings are safe.
     453            'escape06': ('{{ \"this & that\" }}',{}, "this & that" ),
     454
     455            # Iterating outputs safe characters.
     456            'escape07': ('{% for letter in list %}{{ letter }},{% endfor %}',{}, "K,&amp;,R," ),
     457
     458            # Escape requirement survives lookup.
     459            'escape08': ('{{ var.key }}',{ "var": {"key": "this & that" } }, "this &amp; that" ),
     460
    431461            ### COMMENT SYNTAX ########################################################
    432462            'comment-syntax01': ("{# this is hidden #}hello", {}, "hello"),
    433463            'comment-syntax02': ("{# this is hidden #}hello{# foo #}", {}, "hello"),
Back to Top