當前位置: 首頁>>代碼示例>>Python>>正文


Python doctestcompare.LXMLOutputChecker類代碼示例

本文整理匯總了Python中lxml.doctestcompare.LXMLOutputChecker的典型用法代碼示例。如果您正苦於以下問題:Python LXMLOutputChecker類的具體用法?Python LXMLOutputChecker怎麽用?Python LXMLOutputChecker使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了LXMLOutputChecker類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: assertXmlEqual

 def assertXmlEqual(self, want, got):
     checker = LXMLOutputChecker()
     if not checker.check_output(want, got, 0):
         message = checker.output_difference(Example("", want), got, 0)
         for line in difflib.unified_diff(want.splitlines(1), got.splitlines(1), fromfile='want.xml', tofile='got.xml'):
             print line
         raise AssertionError(message)
開發者ID:rigambhir,項目名稱:commcare-hq,代碼行數:7,代碼來源:test_suite.py

示例2: test_encodeEntities

	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()))
開發者ID:wbiz,項目名稱:lxmlxtree,代碼行數:7,代碼來源:test.py

示例3: assert_xml_equal

def assert_xml_equal(got, want):
    got = lxml.html.tostring(got)
    want = lxml.html.tostring(want)
    checker = LXMLOutputChecker()
    if not checker.check_output(want, got, 0):
        message = checker.output_difference(Example("", want), got, 0)
        raise AssertionError(message)
開發者ID:tlevine,項目名稱:unwatermark,代碼行數:7,代碼來源:tests.py

示例4: assertXmlEqual

def assertXmlEqual(result, expect):
    from doctest import Example
    from lxml.doctestcompare import LXMLOutputChecker
    checker = LXMLOutputChecker()
    if not checker.check_output(expect, result, 0):
        message = checker.output_difference(Example("", expect), result, 0)
        raise AssertionError(message)
開發者ID:alexmerser,項目名稱:simplelms,代碼行數:7,代碼來源:base.py

示例5: assertXmlEqual

    def assertXmlEqual(self, got, want):
        """ fail if the two objects are not equal XML serializations
        In case of a failure, both serializations are pretty printed
        with differences marked.
        There is not check well-formedness or against any schema, only
        slightly intelligent matching of the tested string to the reference
        string.

        '...' can be used as a wildcard instead of nodes or attribute values.

        Wildcard Examples:
            <foo>...</foo>
            <foo bar="..." />

        Arguments:
            got -- string to check, as unicode string
            want -- reference string, as unicode string

        Usage Example:
            self.assertXmlEqual(etree.tounicode(...), reference)
        """
        checker = LXMLOutputChecker()
        if not checker.check_output(want, got, 0):
            message = checker.output_difference(Example("", want), got, 0)
            raise AssertionError(message)
開發者ID:IamJeffG,項目名稱:recipe-markdown,代碼行數:25,代碼來源:utils.py

示例6: assertXmlEqual

 def assertXmlEqual(self, want, got):
     # snippet from http://stackoverflow.com/questions/321795/comparing-xml-in-a-unit-test-in-python/7060342#7060342
     checker = LXMLOutputChecker()
     if not checker.check_output(want, got, 0):
         message = "XML mismatch\n\n"
         for line in difflib.unified_diff(want.splitlines(1), got.splitlines(1), fromfile='want.xml', tofile='got.xml'):
             message += line + '\n'
         raise AssertionError(message)
開發者ID:piyushmadan,項目名稱:commcare-hq,代碼行數:8,代碼來源:util.py

示例7: assert_xml_equal

def assert_xml_equal(got, want):
    assert want is not None, 'Wanted XML cannot be None'
    if got is None:
        raise AssertionError('Got input to validate was None')
    checker = LXMLOutputChecker()
    if not checker.check_output(want, got, 0):
        message = checker.output_difference(Example("", want), got, 0)
        raise AssertionError(message)
開發者ID:Yan-waller,項目名稱:s3-tests,代碼行數:8,代碼來源:common.py

示例8: assertXmlEqual

    def assertXmlEqual(self, got, want):
        from lxml.doctestcompare import LXMLOutputChecker
        from doctest import Example

        checker = LXMLOutputChecker()
        if checker.check_output(want, got, 0):
            return
        message = checker.output_difference(Example("", want), got, 0)
        raise AssertionError(message)
開發者ID:gisce,項目名稱:libComXML,代碼行數:9,代碼來源:test_libcomxml.py

示例9: test_insertPIBefore

	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()))
開發者ID:wbiz,項目名稱:lxmlxtree,代碼行數:10,代碼來源:test.py

示例10: assertXmlFilesEqual

    def assertXmlFilesEqual(self, result_filename, expected_filename):
        with open(result_filename) as rf:
            got = rf.read()
        with open(expected_filename) as ef:
            want = ef.read()

        checker = LXMLOutputChecker()
        if not checker.check_output(want, got, 0):
            message = checker.output_difference(Example("", got), want, 0)
            raise AssertionError(message)
開發者ID:jdrago999,項目名稱:tsunami,代碼行數:10,代碼來源:test_ts2tsung.py

示例11: assertXmlEquivalent

    def assertXmlEquivalent(self, got, expect):
        """Asserts both xml parse to the same results
        `got` may be an XML string or lxml Element
        """
        checker = LXMLOutputChecker()

        if isinstance(got, etree._Element):
            got = etree.tostring(got)

        if not checker.check_output(expect, got, PARSE_XML):
            message = checker.output_difference(doctest.Example("", expect), got, PARSE_XML)
            self.fail(message)
開發者ID:AlekseiCherkes,項目名稱:python-xmlunittest,代碼行數:12,代碼來源:xmlunittest.py

示例12: test_wrap

	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()))
開發者ID:wbiz,項目名稱:lxmlxtree,代碼行數:13,代碼來源:test.py

示例13: assertEqualXML

def assertEqualXML(test, expected):
    output_checker = LXMLOutputChecker()
    if not output_checker.check_output(expected, test, PARSE_XML):
        diff = output_checker.output_difference(Example("", expected), test, PARSE_XML)
        msg = diff
        for line in diff.split("\n"):
            if msg == diff:
                msg = msg + "\nDiff summary:\n"
            if "got:" in line or line.strip().startswith(('+', '-')):
                msg = msg + line + "\n"
        if msg == "":
            msg = diff
        raise AssertionError(msg)
開發者ID:kernsuite-debian,項目名稱:lofar,代碼行數:13,代碼來源:test_utils.py

示例14: compare_xml

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 = generated

    check = checker.check_output(expected, generated, PARSE_XML)
    if check is False:
        diff = checker.output_difference(ob, expected, PARSE_XML)
        return diff
開發者ID:LKI,項目名稱:PythonScripts,代碼行數:14,代碼來源:helper.py

示例15: assertXmlEquivalentOutputs

    def assertXmlEquivalentOutputs(self, data, expected):
        """Asserts both XML outputs are equivalent.

        This assertion use the powerful but dangerous feature of
        LXMLOutputChecker. Powerful because one can compare two XML document
        in their meaning, but dangerous because sometimes there is more to
        check than just a kind of output.

        See LXMLOutputChecker documentation for more information.
        """
        checker = LXMLOutputChecker()

        if not checker.check_output(expected, data, PARSE_XML):
            self.fail("Output are not equivalent:\n" "Given: %s\n" "Expected: %s" % (data, expected))
開發者ID:Exirel,項目名稱:python-xmlunittest,代碼行數:14,代碼來源:xmlunittest.py


注:本文中的lxml.doctestcompare.LXMLOutputChecker類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。