aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_exceptions.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2010-03-05 01:37:41 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2010-03-05 01:37:41 +0000
commit524bdae950f36d540b18ee5ad7910fadf45e30d1 (patch)
tree216ce0a596a8aa7c12ea1bc523370b9bc5cbdedb /test/test_exceptions.py
parentafb6caa9df90a8f952dd8fb5da4c7cbd8ce40dc3 (diff)
downloadexternal_python_mako-524bdae950f36d540b18ee5ad7910fadf45e30d1.tar.gz
external_python_mako-524bdae950f36d540b18ee5ad7910fadf45e30d1.tar.bz2
external_python_mako-524bdae950f36d540b18ee5ad7910fadf45e30d1.zip
- RichTraceback(), html_error_template().render(),
text_error_template().render() now accept "error" and "traceback" as optional arguments, and these are now actually used. [ticket:122]
Diffstat (limited to 'test/test_exceptions.py')
-rw-r--r--test/test_exceptions.py28
1 files changed, 24 insertions, 4 deletions
diff --git a/test/test_exceptions.py b/test/test_exceptions.py
index 57b3bac..e64afc2 100644
--- a/test/test_exceptions.py
+++ b/test/test_exceptions.py
@@ -86,7 +86,6 @@ ${u'привет'}
assert 'RuntimeError: test' in html_error
assert "foo = u'&#x65E5;&#x672C;'" in html_error
-
def test_py_unicode_error_html_error_template(self):
try:
raise RuntimeError(u'日本')
@@ -106,10 +105,12 @@ ${foobar}
${self.body()}
""")
- assert '<div class="sourceline">${foobar}</div>' in result_lines(l.get_template("foo.html").render_unicode())
+ assert '<div class="sourceline">${foobar}</div>' in \
+ result_lines(l.get_template("foo.html").render_unicode())
def test_utf8_format_exceptions(self):
- """test that htmlentityreplace formatting is applied to exceptions reported with format_exceptions=True"""
+ """test that htmlentityreplace formatting is applied to
+ exceptions reported with format_exceptions=True"""
l = TemplateLookup(format_exceptions=True)
if util.py3k:
@@ -121,6 +122,25 @@ ${foobar}
assert u'<div class="sourceline">${\'привет\' + foobar}</div>'\
in result_lines(l.get_template("foo.html").render().decode('utf-8'))
else:
- assert '<div class="highlight">2 ${u\'&#x43F;&#x440;&#x438;&#x432;&#x435;&#x442;\' + foobar}</div>' \
+ assert '<div class="highlight">2 ${u\'&#x43F;&#x440;'\
+ '&#x438;&#x432;&#x435;&#x442;\' + foobar}</div>' \
in result_lines(l.get_template("foo.html").render().decode('utf-8'))
+
+ def test_custom_tback(self):
+ try:
+ raise RuntimeError("error 1")
+ foo('bar')
+ except:
+ t, v, tback = sys.exc_info()
+
+ try:
+ raise RuntimeError("error 2")
+ except:
+ html_error = exceptions.html_error_template().render(error=t, traceback=tback)
+
+ # obfuscate the text so that this text
+ # isn't in the 'wrong' exception
+ assert "".join(reversed(")'rab'(oof")) in html_error
+
+ \ No newline at end of file