本文整理汇总了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)