From 6b29775df2d3155bf6076ea103f573c5efbc8883 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Mon, 21 Feb 2011 12:04:21 -0500 Subject: - py3k fixes --- test/templates/read_unicode_py3k.html | 2 +- test/test_lexer.py | 4 ++-- test/test_template.py | 4 ++++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/test/templates/read_unicode_py3k.html b/test/templates/read_unicode_py3k.html index 380d356..c94399e 100644 --- a/test/templates/read_unicode_py3k.html +++ b/test/templates/read_unicode_py3k.html @@ -1,6 +1,6 @@ <% try: - file_content = open(path) + file_content = open(path, encoding='utf-8', errors='ignore') except: raise "Should never execute here" doc_content = ''.join(file_content.readlines()) diff --git a/test/test_lexer.py b/test/test_lexer.py index 006abee..538da97 100644 --- a/test/test_lexer.py +++ b/test/test_lexer.py @@ -342,7 +342,7 @@ class LexerTest(TemplateTest): <% print("hi") for x in range(1,5): - print x + print(x) %> more text <%! @@ -354,7 +354,7 @@ more text TemplateNode({}, [ Text(u'text\n ', (1, 1)), Code(u'\nprint("hi")\nfor x in range(1,5):\n ' - 'print x\n \n', False, (2, 5)), + 'print(x)\n \n', False, (2, 5)), Text(u'\nmore text\n ', (6, 7)), Code(u'\nimport foo\n \n', True, (8, 5)), Text(u'\n', (10, 7))]) diff --git a/test/test_template.py b/test/test_template.py index e8fd6ed..a62783e 100644 --- a/test/test_template.py +++ b/test/test_template.py @@ -328,6 +328,10 @@ class EncodingTest(TemplateTest): template = lookup.get_template('/read_unicode_py3k.html') else: template = lookup.get_template('/read_unicode.html') + # TODO: I've no idea what encoding this file is, Python 3.1.2 + # won't read the file even with open(...encoding='utf-8') unless + # errors is specified. or if there's some quirk in 3.1.2 + # since I'm pretty sure this test worked with py3k when I wrote it. data = template.render(path=self._file_path('internationalization.html')) @skip_if(lambda: util.py3k) -- cgit v1.2.3