diff --git a/django/template/__init__.py b/django/template/__init__.py index 26c6b784ae..3ec5cc09f8 100644 --- a/django/template/__init__.py +++ b/django/template/__init__.py @@ -519,9 +519,9 @@ class FilterExpression(object): args = [] constant_arg, i18n_arg, var_arg = match.group("constant_arg", "i18n_arg", "var_arg") if i18n_arg: - args.append((False, _(i18n_arg.replace('\\', '')))) + args.append((False, _(i18n_arg.replace(r'\"', '"')))) elif constant_arg: - args.append((False, constant_arg.replace('\\', ''))) + args.append((False, constant_arg.replace(r'\"', '"'))) elif var_arg: args.append((True, var_arg)) filter_func = parser.find_filter(filter_name) diff --git a/tests/othertests/dateformat.py b/tests/othertests/dateformat.py index 3350a1f8ab..0287587b4a 100644 --- a/tests/othertests/dateformat.py +++ b/tests/othertests/dateformat.py @@ -1,14 +1,16 @@ -""" +r""" >>> format(my_birthday, '') '' >>> format(my_birthday, 'a') 'p.m.' >>> format(my_birthday, 'A') 'PM' +>>> format(my_birthday, 'd') +'08' >>> format(my_birthday, 'j') -'7' +'8' >>> format(my_birthday, 'l') -'Saturday' +'Sunday' >>> format(my_birthday, 'L') 'False' >>> format(my_birthday, 'm') @@ -24,7 +26,7 @@ >>> format(my_birthday, 'P') '10 p.m.' >>> format(my_birthday, 'r') -'Sat, 7 Jul 1979 22:00:00 +0100' +'Sun, 8 Jul 1979 22:00:00 +0100' >>> format(my_birthday, 's') '00' >>> format(my_birthday, 'S') @@ -34,9 +36,9 @@ >>> format(my_birthday, 'T') 'CET' >>> format(my_birthday, 'U') -'300445200' +'300531600' >>> format(my_birthday, 'w') -'6' +'0' >>> format(my_birthday, 'W') '27' >>> format(my_birthday, 'y') @@ -44,7 +46,7 @@ >>> format(my_birthday, 'Y') '1979' >>> format(my_birthday, 'z') -'188' +'189' >>> format(my_birthday, 'Z') '3600' @@ -57,8 +59,11 @@ >>> format(wintertime, 'O') '+0100' ->>> format(my_birthday, 'Y z \\C\\E\\T') -'1979 188 CET' +>>> format(my_birthday, r'Y z \C\E\T') +'1979 189 CET' + +>>> format(my_birthday, r'jS o\f F') +'8th of July' """ from django.utils import dateformat, translation @@ -70,6 +75,6 @@ translation.activate('en-us') time.tzset() -my_birthday = datetime.datetime(1979, 7, 7, 22, 00) +my_birthday = datetime.datetime(1979, 7, 8, 22, 00) summertime = datetime.datetime(2005, 10, 30, 1, 00) wintertime = datetime.datetime(2005, 10, 30, 4, 00) diff --git a/tests/othertests/defaultfilters.py b/tests/othertests/defaultfilters.py index 9be9c61601..46f2519285 100644 --- a/tests/othertests/defaultfilters.py +++ b/tests/othertests/defaultfilters.py @@ -1,4 +1,4 @@ -""" +r""" >>> floatformat(7.7) '7.7' >>> floatformat(7.0) @@ -12,8 +12,8 @@ >>> floatformat(0.0) '0' ->>> addslashes('"double quotes" and \\'single quotes\\'') -'\\\\"double quotes\\\\" and \\\\\\'single quotes\\\\\\'' +>>> addslashes('"double quotes" and \'single quotes\'') +'\\"double quotes\\" and \\\'single quotes\\\'' >>> capfirst('hello world') 'Hello world' @@ -21,17 +21,17 @@ >>> fix_ampersands('Jack & Jill & Jeroboam') 'Jack & Jill & Jeroboam' ->>> linenumbers('line 1\\nline 2') -'1. line 1\\n2. line 2' +>>> linenumbers('line 1\nline 2') +'1. line 1\n2. line 2' ->>> linenumbers('\\n'.join(['x'] * 10)) -'01. x\\n02. x\\n03. x\\n04. x\\n05. x\\n06. x\\n07. x\\n08. x\\n09. x\\n10. x' +>>> linenumbers('\n'.join(['x'] * 10)) +'01. x\n02. x\n03. x\n04. x\n05. x\n06. x\n07. x\n08. x\n09. x\n10. x' >>> lower('TEST') 'test' ->>> lower(u'\\xcb') # uppercase E umlaut -u'\\xeb' +>>> lower(u'\xcb') # uppercase E umlaut +u'\xeb' >>> make_list('abc') ['a', 'b', 'c'] @@ -48,7 +48,7 @@ u'\\xeb' >>> stringformat(1, 'z') '' ->>> title('a nice title, isn\\'t it?') +>>> title('a nice title, isn\'t it?') "A Nice Title, Isn't It?" @@ -68,8 +68,8 @@ u'\\xeb' >>> upper('Mixed case input') 'MIXED CASE INPUT' ->>> upper(u'\\xeb') # lowercase e umlaut -u'\\xcb' +>>> upper(u'\xeb') # lowercase e umlaut +u'\xcb' >>> urlencode('jack & jill') @@ -91,8 +91,8 @@ u'\\xcb' >>> wordcount('lots of words') 3 ->>> wordwrap('this is a long paragraph of text that really needs to be wrapped I\\'m afraid', 14) -"this is a long\\nparagraph of\\ntext that\\nreally needs\\nto be wrapped\\nI'm afraid" +>>> wordwrap('this is a long paragraph of text that really needs to be wrapped I\'m afraid', 14) +"this is a long\nparagraph of\ntext that\nreally needs\nto be wrapped\nI'm afraid" >>> ljust('test', 10) 'test ' @@ -124,7 +124,7 @@ u'\\xcb' >>> linebreaks('line 1') '
line 1
' ->>> linebreaks('line 1\\nline 2') +>>> linebreaks('line 1\nline 2') 'line 1
line 2