Ticket #7806: tplrf-tests.diff
File tplrf-tests.diff, 6.3 KB (added by , 16 years ago) |
---|
-
tests/regressiontests/templates/tests.py
280 280 'basic-syntax25': ('{{ "fred" }}', {}, "fred"), 281 281 'basic-syntax26': (r'{{ "\"fred\"" }}', {}, "\"fred\""), 282 282 'basic-syntax27': (r'{{ _("\"fred\"") }}', {}, "\"fred\""), 283 'basic-syntax28': ("{{ 'fred' }}", {}, "fred"), 284 'basic-syntax29': (r"{{ '\'fred\'' }}", {}, "'fred'"), 285 'basic-syntax30': (r"{{ _('\'fred\'') }}", {}, "'fred'"), 283 286 287 284 288 # List-index syntax allows a template to access a certain item of a subscriptable object. 285 289 'list-index01': ("{{ var.1 }}", {"var": ["first item", "second item"]}, "second item"), 286 290 … … 364 368 365 369 # Numbers as filter arguments should work 366 370 'filter-syntax19': ('{{ var|truncatewords:1 }}', {"var": "hello world"}, "hello ..."), 371 372 # Single quoted argument 373 'filter-syntax20': (r"{{ var|yesno:'yup,nup,mup' }} {{ var|yesno }}", {"var": True}, 'yup yes'), 367 374 368 375 ### COMMENT SYNTAX ######################################################## 369 376 'comment-syntax01': ("{# this is hidden #}hello", {}, "hello"), … … 407 414 'cycle13': ("{% for i in test %}{% cycle 'a' 'b' %}{{ i }},{% endfor %}", {'test': range(5)}, 'a0,b1,a2,b3,a4,'), 408 415 'cycle14': ("{% cycle one two as foo %}{% cycle foo %}", {'one': '1','two': '2'}, '12'), 409 416 'cycle13': ("{% for i in test %}{% cycle aye bee %}{{ i }},{% endfor %}", {'test': range(5), 'aye': 'a', 'bee': 'b'}, 'a0,b1,a2,b3,a4,'), 417 418 ### EMPTY STRINGS ######################################################### 419 'emptystring01': ("{{ '' }}", {}, ""), 420 'emptystring02': ("{% ifequal foo '' %}x{% endifequal %}", {'foo': ''}, 'x'), 421 'emptystring03': ("{% ifequal foo|default:'' foo %}x{% endifequal %}", {'foo': ''}, 'x'), 410 422 411 423 ### EXCEPTIONS ############################################################ 412 424 … … 576 588 'ifequal08': ('{% ifequal a "test" %}yes{% else %}no{% endifequal %}', {"a": "no"}, "no"), 577 589 'ifequal09': ('{% ifequal a "test" %}yes{% else %}no{% endifequal %}', {}, "no"), 578 590 'ifequal10': ('{% ifequal a b %}yes{% else %}no{% endifequal %}', {}, "yes"), 591 592 ## FILTER EXPRESSIONS AS ARGUMENTS ######################################## 593 'ifequal-filter01': ('{% ifequal a|upper "A" %}x{% endifequal %}', {'a': 'a'}, 'x'), 594 'ifequal-filter02': ('{% ifequal "A" a|upper %}x{% endifequal %}', {'a': 'a'}, 'x'), 595 'ifequal-filter03': ('{% ifequal a|upper b|upper %}x{% endifequal %}', {'a': 'x', 'b': 'X'}, 'x'), 596 'ifequal-filter04': ('{% ifequal x|slice:"1" "a" %}x{% endifequal %}', {'x': 'aaa'}, 'x'), 597 'ifequal-filter05': ('{% ifequal x|slice:"1"|upper "A" %}x{% endifequal %}', {'x': 'aaa'}, 'x'), 579 598 580 599 # SMART SPLITTING 581 600 'ifequal-split01': ('{% ifequal a "test man" %}yes{% else %}no{% endifequal %}', {}, "no"), … … 796 815 you 797 816 gentlemen. 798 817 """), 818 ### NEGATIVE NUMERIC LITERALS ############################################# 819 'negative-numeric-literal01': ('{{ -1 }}', {}, '-1'), 820 'negative-numeric-literal02': ('{{ -2.01 }}', {}, '-2.01'), 821 'negative-numeric-literal03': ('{{ -0.1 }}', {}, '-0.1'), 822 'negative-numeric-literal04': ('{% ifequal -1 -1 %}x{% endifequal %}', {}, 'x'), 823 'negative-numeric-literal05': ('{{ foo|default:-1 }}', {'foo': None}, '-1'), 799 824 800 825 ### REGROUP TAG ########################################################### 801 826 'regroup01': ('{% regroup data by bar as grouped %}' + \ … … 821 846 '{% endfor %},' + \ 822 847 '{% endfor %}', 823 848 {}, ''), 849 850 'regroup03': ('{% regroup data by created|date:"F Y" as grouped %}' + \ 851 '{% for group in grouped %}' + \ 852 '{{ group.grouper }}' + \ 853 '({% for item in group.list %}' + \ 854 '{{ item.created|date:"d" }}' + \ 855 '{% endfor %})' + \ 856 '{% endfor %}', 857 {'data': [ 858 {'created': datetime(2008, 1, 1)}, 859 {'created': datetime(2008, 2, 2)}, 860 {'created': datetime(2008, 3, 3)}, 861 {'created': datetime(2008, 4, 4)}, 862 ]}, 'January 2008(01)February 2008(02)March 2008(03)April 2008(04)'), 824 863 825 864 ### TEMPLATETAG TAG ####################################################### 826 865 'templatetag01': ('{% templatetag openblock %}', {}, '{%'), … … 860 899 861 900 'with-error01': ('{% with dict.key xx key %}{{ key }}{% endwith %}', {'dict': {'key':50}}, template.TemplateSyntaxError), 862 901 'with-error02': ('{% with dict.key as %}{{ key }}{% endwith %}', {'dict': {'key':50}}, template.TemplateSyntaxError), 863 902 864 903 ### NOW TAG ######################################################## 865 904 # Simple case 866 905 'now01': ('{% now "j n Y"%}', {}, str(datetime.now().day) + ' ' + str(datetime.now().month) + ' ' + str(datetime.now().year)), … … 877 916 'url03': ('{% url regressiontests.templates.views.index %}', {}, '/url_tag/'), 878 917 'url04': ('{% url named.client client.id %}', {'client': {'id': 1}}, '/url_tag/named-client/1/'), 879 918 'url05': (u'{% url метка_оператора v %}', {'v': u'Ω'}, '/url_tag/%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4/%CE%A9/'), 919 'url06': (u'{% url "метка_оператора" v %}', {'v': u'Ω'}, '/url_tag/%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4/%CE%A9/'), 880 920 881 921 # Failures 882 922 'url-fail01': ('{% url %}', {}, template.TemplateSyntaxError),