Skip to content

Commit

Permalink
Add tests and release notes for {% apply %} unicode fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
bdarnell committed Oct 5, 2012
1 parent 54c807c commit c590862
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tornado/test/template_test.py
Expand Up @@ -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"))
Expand Down
3 changes: 3 additions & 0 deletions website/sphinx/releases/next.rst
Expand Up @@ -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.