本文整理匯總了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>')