当前位置: 首页>>代码示例>>Python>>正文


Python LXMLOutputChecker.check_output方法代码示例

本文整理汇总了Python中lxml.doctestcompare.LXMLOutputChecker.check_output方法的典型用法代码示例。如果您正苦于以下问题:Python LXMLOutputChecker.check_output方法的具体用法?Python LXMLOutputChecker.check_output怎么用?Python LXMLOutputChecker.check_output使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在lxml.doctestcompare.LXMLOutputChecker的用法示例。


在下文中一共展示了LXMLOutputChecker.check_output方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: assertXmlEqual

# 需要导入模块: from lxml.doctestcompare import LXMLOutputChecker [as 别名]
# 或者: from lxml.doctestcompare.LXMLOutputChecker import check_output [as 别名]
 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,代码行数:9,代码来源:test_suite.py

示例2: assert_xml_equal

# 需要导入模块: from lxml.doctestcompare import LXMLOutputChecker [as 别名]
# 或者: from lxml.doctestcompare.LXMLOutputChecker import check_output [as 别名]
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,代码行数:9,代码来源:tests.py

示例3: assertXmlEqual

# 需要导入模块: from lxml.doctestcompare import LXMLOutputChecker [as 别名]
# 或者: from lxml.doctestcompare.LXMLOutputChecker import check_output [as 别名]
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,代码行数:9,代码来源:base.py

示例4: assertXmlEqual

# 需要导入模块: from lxml.doctestcompare import LXMLOutputChecker [as 别名]
# 或者: from lxml.doctestcompare.LXMLOutputChecker import check_output [as 别名]
    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,代码行数:27,代码来源:utils.py

示例5: assert_xml_equal

# 需要导入模块: from lxml.doctestcompare import LXMLOutputChecker [as 别名]
# 或者: from lxml.doctestcompare.LXMLOutputChecker import check_output [as 别名]
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,代码行数:10,代码来源:common.py

示例6: assertXmlEqual

# 需要导入模块: from lxml.doctestcompare import LXMLOutputChecker [as 别名]
# 或者: from lxml.doctestcompare.LXMLOutputChecker import check_output [as 别名]
 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,代码行数:10,代码来源:util.py

示例7: assertXmlEqual

# 需要导入模块: from lxml.doctestcompare import LXMLOutputChecker [as 别名]
# 或者: from lxml.doctestcompare.LXMLOutputChecker import check_output [as 别名]
    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,代码行数:11,代码来源:test_libcomxml.py

示例8: assertXmlFilesEqual

# 需要导入模块: from lxml.doctestcompare import LXMLOutputChecker [as 别名]
# 或者: from lxml.doctestcompare.LXMLOutputChecker import check_output [as 别名]
    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,代码行数:12,代码来源:test_ts2tsung.py

示例9: assertXmlEquivalent

# 需要导入模块: from lxml.doctestcompare import LXMLOutputChecker [as 别名]
# 或者: from lxml.doctestcompare.LXMLOutputChecker import check_output [as 别名]
    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,代码行数:14,代码来源:xmlunittest.py

示例10: assertEqualXML

# 需要导入模块: from lxml.doctestcompare import LXMLOutputChecker [as 别名]
# 或者: from lxml.doctestcompare.LXMLOutputChecker import check_output [as 别名]
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,代码行数:15,代码来源:test_utils.py

示例11: compare_xml

# 需要导入模块: from lxml.doctestcompare import LXMLOutputChecker [as 别名]
# 或者: from lxml.doctestcompare.LXMLOutputChecker import check_output [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 = 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,代码行数:16,代码来源:helper.py

示例12: assertXmlEquivalentOutputs

# 需要导入模块: from lxml.doctestcompare import LXMLOutputChecker [as 别名]
# 或者: from lxml.doctestcompare.LXMLOutputChecker import check_output [as 别名]
    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,代码行数:16,代码来源:xmlunittest.py

示例13: assert_xml_equal

# 需要导入模块: from lxml.doctestcompare import LXMLOutputChecker [as 别名]
# 或者: from lxml.doctestcompare.LXMLOutputChecker import check_output [as 别名]
def assert_xml_equal(expected_xml, got_xml, context_explanation=""):
    checker = LXMLOutputChecker()
    if not checker.check_output(expected_xml, got_xml, 0):
        raise AssertionError(
            "{context_explanation}{xml_diff}".format(
                context_explanation=(
                    "" if not context_explanation
                    else "\n{0}\n".format(context_explanation)
                ),
                xml_diff=checker.output_difference(
                    doctest.Example("", expected_xml),
                    got_xml,
                    0
                )
            )
        )
开发者ID:HideoYamauchi,项目名称:pcs,代码行数:18,代码来源:assertions.py

示例14: assertXmlEqual

# 需要导入模块: from lxml.doctestcompare import LXMLOutputChecker [as 别名]
# 或者: from lxml.doctestcompare.LXMLOutputChecker import check_output [as 别名]
    def assertXmlEqual(self, expected, actual, normalize=True):
        if normalize:
            expected = parse_normalize(expected)
            actual = parse_normalize(actual)

        # snippet from http://stackoverflow.com/questions/321795/comparing-xml-in-a-unit-test-in-python/7060342#7060342
        checker = LXMLOutputChecker()
        if not checker.check_output(expected, actual, 0):
            message = "XML mismatch\n\n"
            diff = difflib.unified_diff(
                expected.splitlines(1),
                actual.splitlines(1),
                fromfile='want.xml',
                tofile='got.xml'
            )
            for line in diff:
                message += line
            raise AssertionError(message)
开发者ID:dslowikowski,项目名称:commcare-hq,代码行数:20,代码来源:util.py

示例15: assertXmlEqual

# 需要导入模块: from lxml.doctestcompare import LXMLOutputChecker [as 别名]
# 或者: from lxml.doctestcompare.LXMLOutputChecker import check_output [as 别名]
    def assertXmlEqual(self, expected, actual, normalize=True):
        if normalize:
            parser = lxml.etree.XMLParser(remove_blank_text=True)
            parse = lambda *args: normalize_attributes(lxml.etree.XML(*args))
            expected = lxml.etree.tostring(parse(expected, parser), pretty_print=True)
            actual = lxml.etree.tostring(parse(actual, parser), pretty_print=True)

        # snippet from http://stackoverflow.com/questions/321795/comparing-xml-in-a-unit-test-in-python/7060342#7060342
        checker = LXMLOutputChecker()
        if not checker.check_output(expected, actual, 0):
            message = "XML mismatch\n\n"
            diff = difflib.unified_diff(
                expected.splitlines(1),
                actual.splitlines(1),
                fromfile='want.xml',
                tofile='got.xml'
            )
            for line in diff:
                message += line
            raise AssertionError(message)
开发者ID:SEL-Columbia,项目名称:commcare-hq,代码行数:22,代码来源:util.py


注:本文中的lxml.doctestcompare.LXMLOutputChecker.check_output方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。