本文整理匯總了Python中lxml.doctestcompare.LXMLOutputChecker方法的典型用法代碼示例。如果您正苦於以下問題:Python doctestcompare.LXMLOutputChecker方法的具體用法?Python doctestcompare.LXMLOutputChecker怎麽用?Python doctestcompare.LXMLOutputChecker使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類lxml.doctestcompare
的用法示例。
在下文中一共展示了doctestcompare.LXMLOutputChecker方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: equals
# 需要導入模塊: from lxml import doctestcompare [as 別名]
# 或者: from lxml.doctestcompare import LXMLOutputChecker [as 別名]
def equals(self, rhs):
checker = doctestcompare.LXMLOutputChecker()
return checker.check_output(self._xml, rhs, 0)
示例2: compare_xml
# 需要導入模塊: from lxml import doctestcompare [as 別名]
# 或者: from lxml.doctestcompare import LXMLOutputChecker [as 別名]
def compare_xml(generated, expected):
"""Use doctest checking from lxml for comparing XML trees. Returns diff if the two are not the same"""
checker = LXMLOutputChecker()
class DummyDocTest():
pass
ob = DummyDocTest()
ob.want = expected
check = checker.check_output(expected, generated, PARSE_XML)
if check is False:
diff = checker.output_difference(ob, generated, PARSE_XML)
return diff
示例3: check_etree
# 需要導入模塊: from lxml import doctestcompare [as 別名]
# 或者: from lxml.doctestcompare import LXMLOutputChecker [as 別名]
def check_etree(self, conv, tostring=tostring, fromstring=fromstring):
'Returns method(obj, xmlstring) that converts obj to XML and compares'
checker = LXMLOutputChecker()
eq = checker.compare_docs
def compare(obj, *strings):
tree = conv.etree(obj)
self.assertEqual(len(tree), len(strings))
for left, right in zip(tree, strings):
if not eq(left, fromstring(right)):
raise AssertionError('%s != %s' % (decode(tostring(left)), right))
return compare
示例4: assertXmlEqual
# 需要導入模塊: from lxml import doctestcompare [as 別名]
# 或者: from lxml.doctestcompare import LXMLOutputChecker [as 別名]
def assertXmlEqual(self, got, want):
checker = LXMLOutputChecker()
if not checker.check_output(want, got, 0):
message = checker.output_difference(Example("", want), got, 0)
raise AssertionError(message)