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


Python util.safe_repr方法代码示例

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


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

示例1: assertHTMLEqual

# 需要导入模块: from unittest import util [as 别名]
# 或者: from unittest.util import safe_repr [as 别名]
def assertHTMLEqual(self, html1, html2, msg=None):
        """
        Asserts that two HTML snippets are semantically the same.
        Whitespace in most cases is ignored, and attribute ordering is not
        significant. The passed-in arguments must be valid HTML.
        """
        dom1 = assert_and_parse_html(self, html1, msg,
            'First argument is not valid HTML:')
        dom2 = assert_and_parse_html(self, html2, msg,
            'Second argument is not valid HTML:')

        if dom1 != dom2:
            standardMsg = '%s != %s' % (
                safe_repr(dom1, True), safe_repr(dom2, True))
            diff = ('\n' + '\n'.join(difflib.ndiff(
                           six.text_type(dom1).splitlines(),
                           six.text_type(dom2).splitlines())))
            standardMsg = self._truncateMessage(standardMsg, diff)
            self.fail(self._formatMessage(msg, standardMsg)) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:21,代码来源:testcases.py

示例2: assertHTMLEqual

# 需要导入模块: from unittest import util [as 别名]
# 或者: from unittest.util import safe_repr [as 别名]
def assertHTMLEqual(self, html1, html2, msg=None):
        """
        Assert that two HTML snippets are semantically the same.
        Whitespace in most cases is ignored, and attribute ordering is not
        significant. The arguments must be valid HTML.
        """
        dom1 = assert_and_parse_html(self, html1, msg, 'First argument is not valid HTML:')
        dom2 = assert_and_parse_html(self, html2, msg, 'Second argument is not valid HTML:')

        if dom1 != dom2:
            standardMsg = '%s != %s' % (
                safe_repr(dom1, True), safe_repr(dom2, True))
            diff = ('\n' + '\n'.join(difflib.ndiff(
                str(dom1).splitlines(), str(dom2).splitlines(),
            )))
            standardMsg = self._truncateMessage(standardMsg, diff)
            self.fail(self._formatMessage(msg, standardMsg)) 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:19,代码来源:testcases.py

示例3: assertXMLEqual

# 需要导入模块: from unittest import util [as 别名]
# 或者: from unittest.util import safe_repr [as 别名]
def assertXMLEqual(self, xml1, xml2, msg=None):
        """
        Assert that two XML snippets are semantically the same.
        Whitespace in most cases is ignored and attribute ordering is not
        significant. The arguments must be valid XML.
        """
        try:
            result = compare_xml(xml1, xml2)
        except Exception as e:
            standardMsg = 'First or second argument is not valid XML\n%s' % e
            self.fail(self._formatMessage(msg, standardMsg))
        else:
            if not result:
                standardMsg = '%s != %s' % (safe_repr(xml1, True), safe_repr(xml2, True))
                diff = ('\n' + '\n'.join(
                    difflib.ndiff(xml1.splitlines(), xml2.splitlines())
                ))
                standardMsg = self._truncateMessage(standardMsg, diff)
                self.fail(self._formatMessage(msg, standardMsg)) 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:21,代码来源:testcases.py

示例4: assertHTMLEqual

# 需要导入模块: from unittest import util [as 别名]
# 或者: from unittest.util import safe_repr [as 别名]
def assertHTMLEqual(self, html1, html2, msg=None):
        """
        Asserts that two HTML snippets are semantically the same.
        Whitespace in most cases is ignored, and attribute ordering is not
        significant. The passed-in arguments must be valid HTML.
        """
        dom1 = assert_and_parse_html(self, html1, msg, 'First argument is not valid HTML:')
        dom2 = assert_and_parse_html(self, html2, msg, 'Second argument is not valid HTML:')

        if dom1 != dom2:
            standardMsg = '%s != %s' % (
                safe_repr(dom1, True), safe_repr(dom2, True))
            diff = ('\n' + '\n'.join(difflib.ndiff(
                six.text_type(dom1).splitlines(),
                six.text_type(dom2).splitlines(),
            )))
            standardMsg = self._truncateMessage(standardMsg, diff)
            self.fail(self._formatMessage(msg, standardMsg)) 
开发者ID:Yeah-Kun,项目名称:python,代码行数:20,代码来源:testcases.py

示例5: assertXMLEqual

# 需要导入模块: from unittest import util [as 别名]
# 或者: from unittest.util import safe_repr [as 别名]
def assertXMLEqual(self, xml1, xml2, msg=None):
        """
        Asserts that two XML snippets are semantically the same.
        Whitespace in most cases is ignored, and attribute ordering is not
        significant. The passed-in arguments must be valid XML.
        """
        try:
            result = compare_xml(xml1, xml2)
        except Exception as e:
            standardMsg = 'First or second argument is not valid XML\n%s' % e
            self.fail(self._formatMessage(msg, standardMsg))
        else:
            if not result:
                standardMsg = '%s != %s' % (safe_repr(xml1, True), safe_repr(xml2, True))
                diff = ('\n' + '\n'.join(
                    difflib.ndiff(
                        six.text_type(xml1).splitlines(),
                        six.text_type(xml2).splitlines(),
                    )
                ))
                standardMsg = self._truncateMessage(standardMsg, diff)
                self.fail(self._formatMessage(msg, standardMsg)) 
开发者ID:Yeah-Kun,项目名称:python,代码行数:24,代码来源:testcases.py

示例6: assertHTMLNotEqual

# 需要导入模块: from unittest import util [as 别名]
# 或者: from unittest.util import safe_repr [as 别名]
def assertHTMLNotEqual(self, html1, html2, msg=None):
        """Asserts that two HTML snippets are not semantically equivalent."""
        dom1 = assert_and_parse_html(self, html1, msg,
            'First argument is not valid HTML:')
        dom2 = assert_and_parse_html(self, html2, msg,
            'Second argument is not valid HTML:')

        if dom1 == dom2:
            standardMsg = '%s == %s' % (
                safe_repr(dom1, True), safe_repr(dom2, True))
            self.fail(self._formatMessage(msg, standardMsg)) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:13,代码来源:testcases.py

示例7: assertXMLEqual

# 需要导入模块: from unittest import util [as 别名]
# 或者: from unittest.util import safe_repr [as 别名]
def assertXMLEqual(self, xml1, xml2, msg=None):
        """
        Asserts that two XML snippets are semantically the same.
        Whitespace in most cases is ignored, and attribute ordering is not
        significant. The passed-in arguments must be valid XML.
        """
        try:
            result = compare_xml(xml1, xml2)
        except Exception as e:
            standardMsg = 'First or second argument is not valid XML\n%s' % e
            self.fail(self._formatMessage(msg, standardMsg))
        else:
            if not result:
                standardMsg = '%s != %s' % (safe_repr(xml1, True), safe_repr(xml2, True))
                self.fail(self._formatMessage(msg, standardMsg)) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:17,代码来源:testcases.py

示例8: assertXMLNotEqual

# 需要导入模块: from unittest import util [as 别名]
# 或者: from unittest.util import safe_repr [as 别名]
def assertXMLNotEqual(self, xml1, xml2, msg=None):
        """
        Asserts that two XML snippets are not semantically equivalent.
        Whitespace in most cases is ignored, and attribute ordering is not
        significant. The passed-in arguments must be valid XML.
        """
        try:
            result = compare_xml(xml1, xml2)
        except Exception as e:
            standardMsg = 'First or second argument is not valid XML\n%s' % e
            self.fail(self._formatMessage(msg, standardMsg))
        else:
            if result:
                standardMsg = '%s == %s' % (safe_repr(xml1, True), safe_repr(xml2, True))
                self.fail(self._formatMessage(msg, standardMsg)) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:17,代码来源:testcases.py

示例9: assertHTMLNotEqual

# 需要导入模块: from unittest import util [as 别名]
# 或者: from unittest.util import safe_repr [as 别名]
def assertHTMLNotEqual(self, html1, html2, msg=None):
        """Assert that two HTML snippets are not semantically equivalent."""
        dom1 = assert_and_parse_html(self, html1, msg, 'First argument is not valid HTML:')
        dom2 = assert_and_parse_html(self, html2, msg, 'Second argument is not valid HTML:')

        if dom1 == dom2:
            standardMsg = '%s == %s' % (
                safe_repr(dom1, True), safe_repr(dom2, True))
            self.fail(self._formatMessage(msg, standardMsg)) 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:11,代码来源:testcases.py

示例10: assertXMLNotEqual

# 需要导入模块: from unittest import util [as 别名]
# 或者: from unittest.util import safe_repr [as 别名]
def assertXMLNotEqual(self, xml1, xml2, msg=None):
        """
        Assert that two XML snippets are not semantically equivalent.
        Whitespace in most cases is ignored and attribute ordering is not
        significant. The arguments must be valid XML.
        """
        try:
            result = compare_xml(xml1, xml2)
        except Exception as e:
            standardMsg = 'First or second argument is not valid XML\n%s' % e
            self.fail(self._formatMessage(msg, standardMsg))
        else:
            if result:
                standardMsg = '%s == %s' % (safe_repr(xml1, True), safe_repr(xml2, True))
                self.fail(self._formatMessage(msg, standardMsg)) 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:17,代码来源:testcases.py

示例11: assertTrue

# 需要导入模块: from unittest import util [as 别名]
# 或者: from unittest.util import safe_repr [as 别名]
def assertTrue(self, expr, msg=None):
        expr = bool(expr)
        assertionRecorder = self.get_result_emitter('assertionRecorder')
        assertionRecorder.assert_('True', [expr], msg)

        if not expr:
            msg = self._formatMessage(msg, "%s is not true" % safe_repr(expr))
            self.fail(msg) 
开发者ID:AirtestProject,项目名称:PocoUnit,代码行数:10,代码来源:case.py

示例12: assertFalse

# 需要导入模块: from unittest import util [as 别名]
# 或者: from unittest.util import safe_repr [as 别名]
def assertFalse(self, expr, msg=None):
        expr = bool(expr)
        assertionRecorder = self.get_result_emitter('assertionRecorder')
        assertionRecorder.assert_('False', [expr], msg)

        if expr:
            msg = self._formatMessage(msg, "%s is not false" % safe_repr(expr))
            self.fail(msg) 
开发者ID:AirtestProject,项目名称:PocoUnit,代码行数:10,代码来源:case.py

示例13: assertAll

# 需要导入模块: from unittest import util [as 别名]
# 或者: from unittest.util import safe_repr [as 别名]
def assertAll(self, iterable, msg=None):
        """Check for all the value in the given iterable to be True"""
        if not all(iterable):
            standardMsg = 'found false value in %s' % safe_repr(iterable)
            self.fail(self._formatMessage(msg, standardMsg)) 
开发者ID:danielepantaleone,项目名称:eddy,代码行数:7,代码来源:__init__.py

示例14: assertAllIn

# 需要导入模块: from unittest import util [as 别名]
# 或者: from unittest.util import safe_repr [as 别名]
def assertAllIn(self, iterable, container, msg=None):
        """Check for all the item in iterable to be in the given container"""
        for member in iterable:
            if member not in container:
                if member not in container:
                    standardMsg = '%s not found in %s' % (safe_repr(member), safe_repr(container))
                    self.fail(self._formatMessage(msg, standardMsg)) 
开发者ID:danielepantaleone,项目名称:eddy,代码行数:9,代码来源:__init__.py

示例15: assertAny

# 需要导入模块: from unittest import util [as 别名]
# 或者: from unittest.util import safe_repr [as 别名]
def assertAny(self, iterable, msg=None):
        """Check for at least a True value in the given iterable"""
        if not any(iterable):
            standardMsg = 'true value not found in %s' % safe_repr(iterable)
            self.fail(self._formatMessage(msg, standardMsg)) 
开发者ID:danielepantaleone,项目名称:eddy,代码行数:7,代码来源:__init__.py


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