diff options
author | mike bayer <mike_mp@zzzcomputing.com> | 2019-07-08 16:36:03 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@bbpush.zzzcomputing.com> | 2019-07-08 16:36:03 +0000 |
commit | 4663af342bf76a736df36a3ca96e7f974d0e2fef (patch) | |
tree | 971b2f4d3ccf3d2f7dac6235186fb72e4ea3f191 /test | |
parent | c0697963498a934a6323b8e04adf1a92aad25620 (diff) | |
parent | 65f8a3b715e8519ca5ca5d835240fe45aa4b96fa (diff) | |
download | mako-4663af342bf76a736df36a3ca96e7f974d0e2fef.tar.gz |
Merge "Include URI in traceback if filename is unknown"
Diffstat (limited to 'test')
-rw-r--r-- | test/test_exceptions.py | 50 |
1 files changed, 44 insertions, 6 deletions
diff --git a/test/test_exceptions.py b/test/test_exceptions.py index 46fbcdd..2ec46cf 100644 --- a/test/test_exceptions.py +++ b/test/test_exceptions.py @@ -398,10 +398,9 @@ raise RuntimeError(msg) # This is the line. t = l.get_template("foo.html") try: t.render() - assert False except: text_error = exceptions.text_error_template().render_unicode() - assert 'File "foo_html", line 4, in render_body' in text_error + assert 'File "foo.html", line 4, in render_body' in text_error assert "raise RuntimeError(msg) # This is the line." in text_error else: assert False @@ -422,12 +421,51 @@ ${foo()} t = l.get_template("foo.html") try: t.render() - assert False except: text_error = exceptions.text_error_template().render_unicode() - sys.stderr.write(text_error) - assert 'File "foo_html", line 7, in render_body' in text_error - assert 'File "foo_html", line 5, in foo' in text_error + assert 'File "foo.html", line 7, in render_body' in text_error + assert 'File "foo.html", line 5, in foo' in text_error assert "raise RuntimeError(msg) # This is the line." in text_error else: assert False + + def test_alternating_file_names(self): + l = TemplateLookup() + l.put_string( + "base.html", + """ +<%! +def broken(): + raise RuntimeError("Something went wrong.") +%> body starts here +<%block name="foo"> + ${broken()} +</%block> + """, + ) + l.put_string( + "foo.html", + """ +<%inherit file="base.html"/> +<%block name="foo"> + ${parent.foo()} +</%block> + """, + ) + t = l.get_template("foo.html") + try: + t.render() + except: + text_error = exceptions.text_error_template().render_unicode() + assert """ + File "base.html", line 5, in render_body + %> body starts here + File "foo.html", line 4, in render_foo + ${parent.foo()} + File "base.html", line 7, in render_foo + ${broken()} + File "base.html", line 4, in broken + raise RuntimeError("Something went wrong.") +""" in text_error + else: + assert False |