]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Add tests and release notes for {% apply %} unicode fix.
authorBen Darnell <ben@bendarnell.com>
Fri, 5 Oct 2012 04:14:41 +0000 (21:14 -0700)
committerBen Darnell <ben@bendarnell.com>
Fri, 5 Oct 2012 04:14:41 +0000 (21:14 -0700)
tornado/test/template_test.py
website/sphinx/releases/next.rst

index c2468e7580d7be486e9d1185208518dbc09e04ac..04f5c64a79b0ebfa2021a7bcd0cb58d232d1b1b0 100644 (file)
@@ -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"))
index 330d731682fe0d84f6c06446ec2e7350d5303f07..25aebf3d64923c49ed33fa2e06f176b10c7c823a 100644 (file)
@@ -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).