本文整理汇总了Python中tornado.template.ParseError方法的典型用法代码示例。如果您正苦于以下问题:Python template.ParseError方法的具体用法?Python template.ParseError怎么用?Python template.ParseError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tornado.template
的用法示例。
在下文中一共展示了template.ParseError方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_escaping
# 需要导入模块: from tornado import template [as 别名]
# 或者: from tornado.template import ParseError [as 别名]
def test_escaping(self):
self.assertRaises(ParseError, lambda: Template("{{"))
self.assertRaises(ParseError, lambda: Template("{%"))
self.assertEqual(Template("{{!").generate(), b"{{")
self.assertEqual(Template("{%!").generate(), b"{%")
self.assertEqual(Template("{{ 'expr' }} {{!jquery expr}}").generate(),
b"expr {{jquery expr}}")
示例2: test_break_outside_loop
# 需要导入模块: from tornado import template [as 别名]
# 或者: from tornado.template import ParseError [as 别名]
def test_break_outside_loop(self):
try:
Template(utf8("{% break %}"))
raise Exception("Did not get expected exception")
except ParseError:
pass
示例3: test_break_in_apply
# 需要导入模块: from tornado import template [as 别名]
# 或者: from tornado.template import ParseError [as 别名]
def test_break_in_apply(self):
# This test verifies current behavior, although of course it would
# be nice if apply didn't cause seemingly unrelated breakage
try:
Template(utf8("{% for i in [] %}{% apply foo %}{% break %}{% end %}{% end %}"))
raise Exception("Did not get expected exception")
except ParseError:
pass
示例4: test_details
# 需要导入模块: from tornado import template [as 别名]
# 或者: from tornado.template import ParseError [as 别名]
def test_details(self):
loader = DictLoader({
"foo.html": "\n\n{{",
})
with self.assertRaises(ParseError) as cm:
loader.load("foo.html")
self.assertEqual("Missing end expression }} at foo.html:3",
str(cm.exception))
self.assertEqual("foo.html", cm.exception.filename)
self.assertEqual(3, cm.exception.lineno)
示例5: test_escaping
# 需要导入模块: from tornado import template [as 别名]
# 或者: from tornado.template import ParseError [as 别名]
def test_escaping(self):
self.assertRaises(ParseError, lambda: Template("{{"))
self.assertRaises(ParseError, lambda: Template("{%"))
self.assertEqual(Template("{{!").generate(), b"{{")
self.assertEqual(Template("{%!").generate(), b"{%")
self.assertEqual(Template("{#!").generate(), b"{#")
self.assertEqual(
Template("{{ 'expr' }} {{!jquery expr}}").generate(),
b"expr {{jquery expr}}",
)
示例6: test_break_in_apply
# 需要导入模块: from tornado import template [as 别名]
# 或者: from tornado.template import ParseError [as 别名]
def test_break_in_apply(self):
# This test verifies current behavior, although of course it would
# be nice if apply didn't cause seemingly unrelated breakage
try:
Template(
utf8("{% for i in [] %}{% apply foo %}{% break %}{% end %}{% end %}")
)
raise Exception("Did not get expected exception")
except ParseError:
pass
示例7: test_details
# 需要导入模块: from tornado import template [as 别名]
# 或者: from tornado.template import ParseError [as 别名]
def test_details(self):
loader = DictLoader({"foo.html": "\n\n{{"})
with self.assertRaises(ParseError) as cm:
loader.load("foo.html")
self.assertEqual("Missing end expression }} at foo.html:3", str(cm.exception))
self.assertEqual("foo.html", cm.exception.filename)
self.assertEqual(3, cm.exception.lineno)
示例8: test_custom_parse_error
# 需要导入模块: from tornado import template [as 别名]
# 或者: from tornado.template import ParseError [as 别名]
def test_custom_parse_error(self):
# Make sure that ParseErrors remain compatible with their
# pre-4.3 signature.
self.assertEqual("asdf at None:0", str(ParseError("asdf")))
示例9: test_escaping
# 需要导入模块: from tornado import template [as 别名]
# 或者: from tornado.template import ParseError [as 别名]
def test_escaping(self):
self.assertRaises(ParseError, lambda: Template("{{"))
self.assertRaises(ParseError, lambda: Template("{%"))
self.assertEqual(Template("{{!").generate(), b"{{")
self.assertEqual(Template("{%!").generate(), b"{%")
self.assertEqual(Template("{#!").generate(), b"{#")
self.assertEqual(Template("{{ 'expr' }} {{!jquery expr}}").generate(),
b"expr {{jquery expr}}")
示例10: test_escaping
# 需要导入模块: from tornado import template [as 别名]
# 或者: from tornado.template import ParseError [as 别名]
def test_escaping(self):
self.assertRaises(ParseError, lambda: Template("{{"))
self.assertRaises(ParseError, lambda: Template("{%"))
self.assertEqual(Template("{{!").generate(), b("{{"))
self.assertEqual(Template("{%!").generate(), b("{%"))
self.assertEqual(Template("{{ 'expr' }} {{!jquery expr}}").generate(),
b("expr {{jquery expr}}"))