當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。