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