本文整理汇总了Python中django.test.html.HTMLParseError方法的典型用法代码示例。如果您正苦于以下问题:Python html.HTMLParseError方法的具体用法?Python html.HTMLParseError怎么用?Python html.HTMLParseError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.test.html
的用法示例。
在下文中一共展示了html.HTMLParseError方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: assert_and_parse_html
# 需要导入模块: from django.test import html [as 别名]
# 或者: from django.test.html import HTMLParseError [as 别名]
def assert_and_parse_html(self, html, user_msg, msg):
try:
dom = parse_html(html)
except HTMLParseError as e:
standardMsg = '%s\n%s' % (msg, e.msg)
self.fail(self._formatMessage(user_msg, standardMsg))
return dom
示例2: assert_and_parse_html
# 需要导入模块: from django.test import html [as 别名]
# 或者: from django.test.html import HTMLParseError [as 别名]
def assert_and_parse_html(self, html, user_msg, msg):
try:
dom = parse_html(html)
except HTMLParseError as e:
standardMsg = '%s\n%s' % (msg, e)
self.fail(self._formatMessage(user_msg, standardMsg))
return dom
示例3: test_parsing_errors
# 需要导入模块: from django.test import html [as 别名]
# 或者: from django.test.html import HTMLParseError [as 别名]
def test_parsing_errors(self):
with self.assertRaises(AssertionError):
self.assertHTMLEqual('<p>', '')
with self.assertRaises(AssertionError):
self.assertHTMLEqual('', '<p>')
error_msg = (
"First argument is not valid HTML:\n"
"('Unexpected end tag `div` (Line 1, Column 6)', (1, 6))"
)
with self.assertRaisesMessage(AssertionError, error_msg):
self.assertHTMLEqual('< div></ div>', '<div></div>')
with self.assertRaises(HTMLParseError):
parse_html('</p>')