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

- Fixed call to "unicode.strip" in

  exceptions.text_error_template which
  is not Py3k compatible.  [ticket:137]
parent 6fbcfe7a
No related branches found
Tags rel_0_2_1
No related merge requests found
0.3.4
- Fixed call to "unicode.strip" in
exceptions.text_error_template which
is not Py3k compatible. [ticket:137]
0.3.3 0.3.3
- Added conditional to RichTraceback - Added conditional to RichTraceback
such that if no traceback is passed such that if no traceback is passed
......
...@@ -5,5 +5,5 @@ ...@@ -5,5 +5,5 @@
# the MIT License: http://www.opensource.org/licenses/mit-license.php # the MIT License: http://www.opensource.org/licenses/mit-license.php
__version__ = '0.3.3' __version__ = '0.3.4'
...@@ -247,7 +247,7 @@ def text_error_template(lookup=None): ...@@ -247,7 +247,7 @@ def text_error_template(lookup=None):
Traceback (most recent call last): Traceback (most recent call last):
% for (filename, lineno, function, line) in tback.traceback: % for (filename, lineno, function, line) in tback.traceback:
File "${filename}", line ${lineno}, in ${function or '?'} File "${filename}", line ${lineno}, in ${function or '?'}
${line | unicode.strip} ${line | trim}
% endfor % endfor
${tback.errorname}: ${tback.message} ${tback.errorname}: ${tback.message}
""") """)
......
...@@ -17,12 +17,12 @@ class ExceptionsTest(TemplateTest): ...@@ -17,12 +17,12 @@ class ExceptionsTest(TemplateTest):
try: try:
template = Template(code) template = Template(code)
template.render_unicode() template.render_unicode()
assert False
except exceptions.CompileException, ce: except exceptions.CompileException, ce:
html_error = exceptions.html_error_template().render_unicode() html_error = exceptions.html_error_template().render_unicode()
assert ("CompileException: Fragment 'i = 0' is not a partial " assert ("CompileException: Fragment 'i = 0' is not a partial "
"control statement") in html_error "control statement") in html_error
assert '<style>' in html_error assert '<style>' in html_error
assert '</style>' in html_error
html_error_stripped = html_error.strip() html_error_stripped = html_error.strip()
assert html_error_stripped.startswith('<html>') assert html_error_stripped.startswith('<html>')
assert html_error_stripped.endswith('</html>') assert html_error_stripped.endswith('</html>')
...@@ -30,18 +30,30 @@ class ExceptionsTest(TemplateTest): ...@@ -30,18 +30,30 @@ class ExceptionsTest(TemplateTest):
not_full = exceptions.html_error_template().\ not_full = exceptions.html_error_template().\
render_unicode(full=False) render_unicode(full=False)
assert '<html>' not in not_full assert '<html>' not in not_full
assert '</html>' not in not_full
assert '<style>' in not_full assert '<style>' in not_full
assert '</style>' in not_full
no_css = exceptions.html_error_template().\ no_css = exceptions.html_error_template().\
render_unicode(css=False) render_unicode(css=False)
assert '<style>' not in no_css assert '<style>' not in no_css
assert '</style>' not in no_css
else: else:
assert False, ("This function should trigger a CompileException, " assert False, ("This function should trigger a CompileException, "
"but didn't") "but didn't")
def test_text_error_template(self):
code = """
% i = 0
"""
try:
template = Template(code)
template.render_unicode()
assert False
except exceptions.CompileException, ce:
text_error = exceptions.text_error_template().render_unicode()
assert 'Traceback (most recent call last):' in text_error
assert ("CompileException: Fragment 'i = 0' is not a partial "
"control statement") in text_error
def test_utf8_html_error_template(self): def test_utf8_html_error_template(self):
"""test the html_error_template with a Template containing utf8 """test the html_error_template with a Template containing utf8
chars""" chars"""
......
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