Changeset 2713
- Timestamp:
- 04/18/06 08:41:21 (3 years ago)
- Files:
-
- django/branches/magic-removal/django/template/__init__.py (modified) (1 diff)
- django/branches/magic-removal/tests/othertests/dateformat.py (modified) (7 diffs)
- django/branches/magic-removal/tests/othertests/defaultfilters.py (modified) (10 diffs)
- django/branches/magic-removal/tests/othertests/templates.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/magic-removal/django/template/__init__.py
r2604 r2713 520 520 constant_arg, i18n_arg, var_arg = match.group("constant_arg", "i18n_arg", "var_arg") 521 521 if i18n_arg: 522 args.append((False, _(i18n_arg.replace( '\\', ''))))522 args.append((False, _(i18n_arg.replace(r'\"', '"')))) 523 523 elif constant_arg: 524 args.append((False, constant_arg.replace( '\\', '')))524 args.append((False, constant_arg.replace(r'\"', '"'))) 525 525 elif var_arg: 526 526 args.append((True, var_arg)) django/branches/magic-removal/tests/othertests/dateformat.py
r1146 r2713 1 """1 r""" 2 2 >>> format(my_birthday, '') 3 3 '' … … 6 6 >>> format(my_birthday, 'A') 7 7 'PM' 8 >>> format(my_birthday, 'd') 9 '08' 8 10 >>> format(my_birthday, 'j') 9 ' 7'11 '8' 10 12 >>> format(my_birthday, 'l') 11 'S aturday'13 'Sunday' 12 14 >>> format(my_birthday, 'L') 13 15 'False' … … 25 27 '10 p.m.' 26 28 >>> format(my_birthday, 'r') 27 'S at, 7Jul 1979 22:00:00 +0100'29 'Sun, 8 Jul 1979 22:00:00 +0100' 28 30 >>> format(my_birthday, 's') 29 31 '00' … … 35 37 'CET' 36 38 >>> format(my_birthday, 'U') 37 '300 445200'39 '300531600' 38 40 >>> format(my_birthday, 'w') 39 ' 6'41 '0' 40 42 >>> format(my_birthday, 'W') 41 43 '27' … … 45 47 '1979' 46 48 >>> format(my_birthday, 'z') 47 '18 8'49 '189' 48 50 >>> format(my_birthday, 'Z') 49 51 '3600' … … 58 60 '+0100' 59 61 60 >>> format(my_birthday, 'Y z \\C\\E\\T') 61 '1979 188 CET' 62 >>> format(my_birthday, r'Y z \C\E\T') 63 '1979 189 CET' 64 65 >>> format(my_birthday, r'jS o\f F') 66 '8th of July' 62 67 """ 63 68 … … 71 76 time.tzset() 72 77 73 my_birthday = datetime.datetime(1979, 7, 7, 22, 00)78 my_birthday = datetime.datetime(1979, 7, 8, 22, 00) 74 79 summertime = datetime.datetime(2005, 10, 30, 1, 00) 75 80 wintertime = datetime.datetime(2005, 10, 30, 4, 00) django/branches/magic-removal/tests/othertests/defaultfilters.py
r2393 r2713 1 """1 r""" 2 2 >>> floatformat(7.7) 3 3 '7.7' … … 13 13 '0' 14 14 15 >>> addslashes('"double quotes" and \ \'single quotes\\'')16 '\\ \\"double quotes\\\\" and \\\\\\'single quotes\\\\\\''15 >>> addslashes('"double quotes" and \'single quotes\'') 16 '\\"double quotes\\" and \\\'single quotes\\\'' 17 17 18 18 >>> capfirst('hello world') … … 22 22 'Jack & Jill & Jeroboam' 23 23 24 >>> linenumbers('line 1\ \nline 2')25 '1. line 1\ \n2. line 2'26 27 >>> linenumbers('\ \n'.join(['x'] * 10))28 '01. x\ \n02. x\\n03. x\\n04. x\\n05. x\\n06. x\\n07. x\\n08. x\\n09. x\\n10. x'24 >>> linenumbers('line 1\nline 2') 25 '1. line 1\n2. line 2' 26 27 >>> linenumbers('\n'.join(['x'] * 10)) 28 '01. x\n02. x\n03. x\n04. x\n05. x\n06. x\n07. x\n08. x\n09. x\n10. x' 29 29 30 30 >>> lower('TEST') 31 31 'test' 32 32 33 >>> lower(u'\ \xcb') # uppercase E umlaut34 u'\ \xeb'33 >>> lower(u'\xcb') # uppercase E umlaut 34 u'\xeb' 35 35 36 36 >>> make_list('abc') … … 49 49 '' 50 50 51 >>> title('a nice title, isn\ \'t it?')51 >>> title('a nice title, isn\'t it?') 52 52 "A Nice Title, Isn't It?" 53 53 … … 69 69 'MIXED CASE INPUT' 70 70 71 >>> upper(u'\ \xeb') # lowercase e umlaut72 u'\ \xcb'71 >>> upper(u'\xeb') # lowercase e umlaut 72 u'\xcb' 73 73 74 74 … … 92 92 3 93 93 94 >>> wordwrap('this is a long paragraph of text that really needs to be wrapped I\ \'m afraid', 14)95 "this is a long\ \nparagraph of\\ntext that\\nreally needs\\nto be wrapped\\nI'm afraid"94 >>> wordwrap('this is a long paragraph of text that really needs to be wrapped I\'m afraid', 14) 95 "this is a long\nparagraph of\ntext that\nreally needs\nto be wrapped\nI'm afraid" 96 96 97 97 >>> ljust('test', 10) … … 125 125 '<p>line 1</p>' 126 126 127 >>> linebreaks('line 1\ \nline 2')127 >>> linebreaks('line 1\nline 2') 128 128 '<p>line 1<br />line 2</p>' 129 129 … … 134 134 'some html with alert("You smell") disallowed tags' 135 135 136 >>> dictsort([{'age': 23, 'name': 'Barbara-Ann'},\ 137 {'age': 63, 'name': 'Ra Ra Rasputin'},\ 138 {'name': 'Jonny B Goode', 'age': 18}], 'age') 139 [{'age': 18, 'name': 'Jonny B Goode'},\ 140 {'age': 23, 'name': 'Barbara-Ann'},\ 141 {'age': 63, 'name': 'Ra Ra Rasputin'}] 142 143 >>> dictsortreversed([{'age': 23, 'name': 'Barbara-Ann'},\ 144 {'age': 63, 'name': 'Ra Ra Rasputin'},\ 145 {'name': 'Jonny B Goode', 'age': 18}], 'age') 146 [{'age': 63, 'name': 'Ra Ra Rasputin'},\ 147 {'age': 23, 'name': 'Barbara-Ann'},\ 148 {'age': 18, 'name': 'Jonny B Goode'}] 136 >>> dictsort([{'age': 23, 'name': 'Barbara-Ann'}, 137 ... {'age': 63, 'name': 'Ra Ra Rasputin'}, 138 ... {'name': 'Jonny B Goode', 'age': 18}], 'age') 139 [{'age': 18, 'name': 'Jonny B Goode'}, {'age': 23, 'name': 'Barbara-Ann'}, {'age': 63, 'name': 'Ra Ra Rasputin'}] 140 141 >>> dictsortreversed([{'age': 23, 'name': 'Barbara-Ann'}, 142 ... {'age': 63, 'name': 'Ra Ra Rasputin'}, 143 ... {'name': 'Jonny B Goode', 'age': 18}], 'age') 144 [{'age': 63, 'name': 'Ra Ra Rasputin'}, {'age': 23, 'name': 'Barbara-Ann'}, {'age': 18, 'name': 'Jonny B Goode'}] 149 145 150 146 >>> first([0,1,2]) … … 197 193 198 194 >>> unordered_list(['item 1', []]) 199 '\ \t<li>item 1</li>'195 '\t<li>item 1</li>' 200 196 201 197 >>> unordered_list(['item 1', [['item 1.1', []]]]) 202 '\ \t<li>item 1\\n\\t<ul>\\n\\t\\t<li>item 1.1</li>\\n\\t</ul>\\n\\t</li>'198 '\t<li>item 1\n\t<ul>\n\t\t<li>item 1.1</li>\n\t</ul>\n\t</li>' 203 199 204 200 >>> unordered_list(['item 1', [['item 1.1', []], ['item 1.2', []]]]) 205 '\ \t<li>item 1\\n\\t<ul>\\n\\t\\t<li>item 1.1</li>\\n\\t\\t<li>item 1.2</li>\\n\\t</ul>\\n\\t</li>'201 '\t<li>item 1\n\t<ul>\n\t\t<li>item 1.1</li>\n\t\t<li>item 1.2</li>\n\t</ul>\n\t</li>' 206 202 207 203 >>> add('1', '2') … … 229 225 >>> date(datetime.datetime(2005, 12, 29), "d F Y") 230 226 '29 December 2005' 227 >>> date(datetime.datetime(2005, 12, 29), r'jS o\f F') 228 '29th of December' 231 229 232 230 # real testing of time() is done in dateformat.py django/branches/magic-removal/tests/othertests/templates.py
r2030 r2713 5 5 from django.template import loader 6 6 from django.utils.translation import activate, deactivate, install 7 from datetime import datetime 7 8 import traceback 8 9 … … 152 153 # the exception propogates 153 154 'basic-syntax34': (r'1{{ var.method4 }}2', {"var": SomeClass()}, SomeOtherException), 155 156 # Escaped backslash in argument 157 'basic-syntax35': (r'{{ var|default_if_none:"foo\bar" }}', {"var": None}, r'foo\bar'), 158 159 # Escaped backslash using known escape char 160 'basic-syntax35': (r'{{ var|default_if_none:"foo\now" }}', {"var": None}, r'foo\now'), 154 161 155 162 ### COMMENT TAG ########################################################### … … 434 441 'widthratio09': ('{% widthratio a b %}', {'a':50,'b':100}, template.TemplateSyntaxError), 435 442 'widthratio10': ('{% widthratio a b 100.0 %}', {'a':50,'b':100}, template.TemplateSyntaxError), 443 444 ### NOW TAG ######################################################## 445 # Simple case 446 'now01' : ('{% now "j n Y"%}', {}, str(datetime.now().day) + ' ' + str(datetime.now().month) + ' ' + str(datetime.now().year)), 447 448 # Check parsing of escaped and special characters 449 'now02' : ('{% now "j "n" Y"%}', {}, template.TemplateSyntaxError), 450 # 'now03' : ('{% now "j \"n\" Y"%}', {}, str(datetime.now().day) + '"' + str(datetime.now().month) + '"' + str(datetime.now().year)), 451 # 'now04' : ('{% now "j \nn\n Y"%}', {}, str(datetime.now().day) + '\n' + str(datetime.now().month) + '\n' + str(datetime.now().year)) 436 452 } 437 453
