Skip to content
Snippets Groups Projects
Commit 64c7ba7b authored by Mike Bayer's avatar Mike Bayer
Browse files

unit tests for input_encoding, non double-decode of unicode object

parent 902519ed
No related branches found
No related tags found
No related merge requests found
......@@ -56,7 +56,18 @@ class EncodingTest(unittest.TestCase):
% endif
""".encode('utf-8'))
assert template.render_unicode().strip() == u"""hi, drôle de petit voix m’a réveillé."""
def test_input_encoding(self):
"""test the 'input_encoding' flag on Template, and that unicode objects arent double-decoded"""
s2 = u"hello ${f(u'śląsk')}"
res = Template(s2, input_encoding='utf-8').render_unicode(f=lambda x:x)
assert res == u"hello śląsk"
s2 = u"# -*- coding: utf-8 -*-\nhello ${f(u'śląsk')}"
res = Template(s2).render_unicode(f=lambda x:x)
assert res == u"hello śląsk"
def test_encoding(self):
val = u"""Alors vous imaginez ma surprise, au lever du jour, quand une drôle de petit voix m’a réveillé. Elle disait: « S’il vous plaît… dessine-moi un mouton! »"""
template = Template(val, output_encoding='utf-8')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment