]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Add a simple template test and make it pass in python 3
authorBen Darnell <ben@bendarnell.com>
Sun, 29 May 2011 22:21:07 +0000 (15:21 -0700)
committerBen Darnell <ben@bendarnell.com>
Sun, 29 May 2011 22:21:07 +0000 (15:21 -0700)
tornado/template.py
tornado/test/runtests.py
tornado/test/template_test.py [new file with mode: 0644]

index ff8bbba98f3ff152c24b488aefd163f1574ce047..67b17335422424e8e230ea3ac141d1d8f98343e1 100644 (file)
@@ -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:
index 2fa98e9692e00a016c287148fc327ca70f411864..683e9aa6848269c96710bf973354645230bde861 100755 (executable)
@@ -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 (file)
index 0000000..66a3129
--- /dev/null
@@ -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!")