From: Ben Darnell Date: Fri, 5 Oct 2012 04:14:41 +0000 (-0700) Subject: Add tests and release notes for {% apply %} unicode fix. X-Git-Tag: v3.0.0~245 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c59086221b8db4d9cc6fd127411ee5ffcf33edf8;p=thirdparty%2Ftornado.git Add tests and release notes for {% apply %} unicode fix. --- diff --git a/tornado/test/template_test.py b/tornado/test/template_test.py index c2468e758..04f5c64a7 100644 --- a/tornado/test/template_test.py +++ b/tornado/test/template_test.py @@ -97,6 +97,18 @@ class TemplateTest(unittest.TestCase): template = Template(utf8("{% apply upper %}foo{% end %}")) self.assertEqual(template.generate(upper=upper), b("FOO")) + def test_unicode_apply(self): + def upper(s): + return to_unicode(s).upper() + template = Template(utf8(u"{% apply upper %}foo \u00e9{% end %}")) + self.assertEqual(template.generate(upper=upper), utf8(u"FOO \u00c9")) + + def test_bytes_apply(self): + def upper(s): + return utf8(to_unicode(s).upper()) + template = Template(utf8(u"{% apply upper %}foo \u00e9{% end %}")) + self.assertEqual(template.generate(upper=upper), utf8(u"FOO \u00c9")) + def test_if(self): template = Template(utf8("{% if x > 4 %}yes{% else %}no{% end %}")) self.assertEqual(template.generate(x=5), b("yes")) diff --git a/website/sphinx/releases/next.rst b/website/sphinx/releases/next.rst index 330d73168..25aebf3d6 100644 --- a/website/sphinx/releases/next.rst +++ b/website/sphinx/releases/next.rst @@ -138,3 +138,6 @@ In progress ``ECONNRESET`` error, rather than logging it as an error. * `HTTPServer` no longer logs an error when it is unable to read a second request from an HTTP 1.1 keep-alive connection. +* The ``{% apply %}`` directive now works properly with functions that return + both unicode strings and byte strings (previously only byte strings were + supported).