Skip to content

Commit

Permalink
py3k fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
zzzeek committed Feb 2, 2012
1 parent 1efbc03 commit 70dec0a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
10 changes: 8 additions & 2 deletions test/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,16 @@ def test_utf8_html_error_template(self):
template.render_unicode()
except exceptions.CompileException, ce:
html_error = exceptions.html_error_template().render()
assert ("CompileException: Fragment 'if 2 == 2: /an "
if util.py3k:
assert ("CompileException: Fragment 'if 2 == 2: /an "
"error' is not a partial control statement "
"at line: 2 char: 1") in \
"at line: 2 char: 1").encode(sys.getdefaultencoding(), 'htmlentityreplace') in \
html_error
else:
assert ("CompileException: Fragment 'if 2 == 2: /an "
"error' is not a partial control statement "
"at line: 2 char: 1") in \
html_error

if util.py3k:
assert u"3 ${'привет'}".encode(sys.getdefaultencoding(),
Expand Down
16 changes: 12 additions & 4 deletions test/test_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,18 @@ def test_escapes_html_tags(self):
except:
# <h3>Exception: <span style="color:red">Foobar</span></h3>
markup = html_error_template().render(full=False, css=False)
print markup
assert '<span style="color:red">Foobar</span></h3>' not in markup
assert '&lt;span style=&#34;color:red&#34;&gt;Foobar&lt;/span&gt;' in markup

if util.py3k:
assert '<span style="color:red">Foobar</span></h3>'\
.encode('ascii') not in markup
assert '&lt;span style=&#34;color:red&#34;'\
'&gt;Foobar&lt;/span&gt;'\
.encode('ascii') in markup
else:
assert '<span style="color:red">Foobar</span></h3>' \
not in markup
assert '&lt;span style=&#34;color:red&#34;'\
'&gt;Foobar&lt;/span&gt;' in markup

def test_unicode(self):
self._do_memory_test(
u"""Alors vous imaginez ma surprise, au lever du jour, quand une drôle de petite voix m’a réveillé. Elle disait: « S’il vous plaît… dessine-moi un mouton! »""",
Expand Down

0 comments on commit 70dec0a

Please sign in to comment.