本文整理汇总了Python中lxml.doctestcompare.LXMLOutputChecker.compare_docs方法的典型用法代码示例。如果您正苦于以下问题:Python LXMLOutputChecker.compare_docs方法的具体用法?Python LXMLOutputChecker.compare_docs怎么用?Python LXMLOutputChecker.compare_docs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lxml.doctestcompare.LXMLOutputChecker
的用法示例。
在下文中一共展示了LXMLOutputChecker.compare_docs方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_encodeEntities
# 需要导入模块: from lxml.doctestcompare import LXMLOutputChecker [as 别名]
# 或者: from lxml.doctestcompare.LXMLOutputChecker import compare_docs [as 别名]
def test_encodeEntities(self):
doc = xtree('testdata/test_data.xml')
doc.parse(False)
r = xtree('testdata/r_test_encode.xml')
r.parse(False)
checker = LXMLOutputChecker()
self.assertTrue(checker.compare_docs(r.tree.getroot(),doc.tree.getroot()))
示例2: test_insertPIBefore
# 需要导入模块: from lxml.doctestcompare import LXMLOutputChecker [as 别名]
# 或者: from lxml.doctestcompare.LXMLOutputChecker import compare_docs [as 别名]
def test_insertPIBefore(self):
doc = xtree('testdata/test_wrap.xml')
doc.parse(False)
for text in doc.tree.xpath('//text'):
pi = etree.ProcessingInstruction('PI', 'Pb')
doc.insert_node(text,'stuff',pi,True)
r = xtree('testdata/r_test_insertPIBefore.xml')
r.parse(False)
checker = LXMLOutputChecker()
self.assertTrue(checker.compare_docs(r.tree.getroot(),doc.tree.getroot()))
示例3: test_wrap
# 需要导入模块: from lxml.doctestcompare import LXMLOutputChecker [as 别名]
# 或者: from lxml.doctestcompare.LXMLOutputChecker import compare_docs [as 别名]
def test_wrap(self):
doc = xtree('testdata/test_wrap.xml')
doc.parse(False)
if not doc.is_valid:
if not doc.errors is None: print(doc.errors)
for text in doc.tree.xpath('//text'):
el = etree.Element('EL')
el.set('atr', 'test')
doc.wrap_text(text,'text',el)
r = xtree('testdata/r_test_wrap.xml')
r.parse(False)
checker = LXMLOutputChecker()
self.assertTrue(checker.compare_docs(r.tree.getroot(),doc.tree.getroot()))