def test_extract_jinja_error_syntax_error(data_dir):
tpl_name = 'template_with_syntax_error.txt'
try:
templates.render(unicode(data_dir), tpl_name, {})
except jinja2.TemplateSyntaxError:
stack, error = templates.extract_jinja_error(sys.exc_info())
tpl_path = data_dir.join(tpl_name)
assert stack == [
' File "%s", line 1' % tpl_path,
' {{ foo',
]
assert error == "Syntax error: unexpected end of template, expected " \
"'end of print statement'"
评论列表
文章目录