Permalink
Browse files

Add tests and release notes for {% apply %} unicode fix.

  • Loading branch information...
1 parent 54c807c commit c59086221b8db4d9cc6fd127411ee5ffcf33edf8 @bdarnell bdarnell committed Oct 5, 2012
Showing with 15 additions and 0 deletions.
  1. +12 −0 tornado/test/template_test.py
  2. +3 −0 website/sphinx/releases/next.rst
View
12 tornado/test/template_test.py
@@ -97,6 +97,18 @@ def upper(s):
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"))
View
3 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).

0 comments on commit c590862

Please sign in to comment.