From: Ben Darnell Date: Sun, 29 May 2011 22:21:07 +0000 (-0700) Subject: Add a simple template test and make it pass in python 3 X-Git-Tag: v2.0.0~52 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6439fd326292d278be5b9a93acd7edc54d66f8a7;p=thirdparty%2Ftornado.git Add a simple template test and make it pass in python 3 --- diff --git a/tornado/template.py b/tornado/template.py index ff8bbba98..67b173354 100644 --- a/tornado/template.py +++ b/tornado/template.py @@ -101,7 +101,7 @@ class Template(object): if compress_whitespace is None: compress_whitespace = name.endswith(".html") or \ name.endswith(".js") - reader = _TemplateReader(name, escape.utf8(template_string)) + reader = _TemplateReader(name, escape.native_str(template_string)) self.file = _File(_parse(reader)) self.code = self._generate_python(loader, compress_whitespace) try: diff --git a/tornado/test/runtests.py b/tornado/test/runtests.py index 2fa98e969..683e9aa68 100755 --- a/tornado/test/runtests.py +++ b/tornado/test/runtests.py @@ -13,6 +13,7 @@ TEST_MODULES = [ 'tornado.test.iostream_test', 'tornado.test.simple_httpclient_test', 'tornado.test.stack_context_test', + 'tornado.test.template_test', 'tornado.test.testing_test', 'tornado.test.web_test', ] diff --git a/tornado/test/template_test.py b/tornado/test/template_test.py new file mode 100644 index 000000000..66a31291a --- /dev/null +++ b/tornado/test/template_test.py @@ -0,0 +1,8 @@ +from tornado.template import Template +from tornado.testing import LogTrapTestCase + +class TemplateTest(LogTrapTestCase): + def test_simple(self): + template = Template("Hello {{ name }}!") + self.assertEqual(template.generate(name="Ben"), + "Hello Ben!")