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


Python unittest.TextTestResult方法代碼示例

本文整理匯總了Python中unittest.TextTestResult方法的典型用法代碼示例。如果您正苦於以下問題:Python unittest.TextTestResult方法的具體用法?Python unittest.TextTestResult怎麽用?Python unittest.TextTestResult使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在unittest的用法示例。


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

示例1: debugTestRunner

# 需要導入模塊: import unittest [as 別名]
# 或者: from unittest import TextTestResult [as 別名]
def debugTestRunner(post_mortem=None):
    """unittest runner doing post mortem debugging on failing tests"""
    if post_mortem is None and not OPTS.purge_temp:
        post_mortem = pdb.post_mortem
    class DebugTestResult(unittest.TextTestResult):
        def addError(self, test, err):
            # called before tearDown()
            traceback.print_exception(*err)
            if post_mortem:
                post_mortem(err[2])
            super(DebugTestResult, self).addError(test, err)
        def addFailure(self, test, err):
            traceback.print_exception(*err)
            if post_mortem:            
                post_mortem(err[2])
            super(DebugTestResult, self).addFailure(test, err)
    return unittest.TextTestRunner(resultclass=DebugTestResult) 
開發者ID:VLSIDA,項目名稱:OpenRAM,代碼行數:19,代碼來源:testutils.py

示例2: run_all

# 需要導入模塊: import unittest [as 別名]
# 或者: from unittest import TextTestResult [as 別名]
def run_all():
        """ Run all unittests of tellurium.

        :return: results of unittest
        :rtype: unittest.TextTestResult
        """
        import matplotlib
        backend = matplotlib.rcParams['backend']
        matplotlib.pyplot.switch_backend("Agg")

        # get the test modules and add to test suite
        modules = TestRunner.find_test_modules()

        suites = [unittest.defaultTestLoader.loadTestsFromName(s) for s in modules]
        testSuite = unittest.TestSuite(suites)
        results = unittest.TextTestRunner(verbosity=2).run(testSuite)
        matplotlib.pyplot.switch_backend(backend)
        return results 
開發者ID:sys-bio,項目名稱:tellurium,代碼行數:20,代碼來源:test_runner.py

示例3: test_init

# 需要導入模塊: import unittest [as 別名]
# 或者: from unittest import TextTestResult [as 別名]
def test_init(self):
        runner = unittest.TextTestRunner()
        self.assertFalse(runner.failfast)
        self.assertFalse(runner.buffer)
        self.assertEqual(runner.verbosity, 1)
        self.assertEqual(runner.warnings, None)
        self.assertTrue(runner.descriptions)
        self.assertEqual(runner.resultclass, unittest.TextTestResult) 
開發者ID:war-and-code,項目名稱:jawfish,代碼行數:10,代碼來源:test_runner.py

示例4: test_tracebacks

# 需要導入模塊: import unittest [as 別名]
# 或者: from unittest import TextTestResult [as 別名]
def test_tracebacks(self):
        @patch.object(Foo, 'f', object())
        def test():
            raise AssertionError
        try:
            test()
        except:
            err = sys.exc_info()

        result = unittest.TextTestResult(None, None, 0)
        traceback = result._exc_info_to_string(err, self)
        self.assertIn('raise AssertionError', traceback) 
開發者ID:war-and-code,項目名稱:jawfish,代碼行數:14,代碼來源:testpatch.py

示例5: testGetDescriptionWithoutDocstring

# 需要導入模塊: import unittest [as 別名]
# 或者: from unittest import TextTestResult [as 別名]
def testGetDescriptionWithoutDocstring(self):
        result = unittest.TextTestResult(None, True, 1)
        self.assertEqual(
                result.getDescription(self),
                'testGetDescriptionWithoutDocstring (' + __name__ +
                '.Test_TestResult)') 
開發者ID:war-and-code,項目名稱:jawfish,代碼行數:8,代碼來源:test_result.py

示例6: testGetDescriptionWithOneLineDocstring

# 需要導入模塊: import unittest [as 別名]
# 或者: from unittest import TextTestResult [as 別名]
def testGetDescriptionWithOneLineDocstring(self):
        """Tests getDescription() for a method with a docstring."""
        result = unittest.TextTestResult(None, True, 1)
        self.assertEqual(
                result.getDescription(self),
               ('testGetDescriptionWithOneLineDocstring '
                '(' + __name__ + '.Test_TestResult)\n'
                'Tests getDescription() for a method with a docstring.')) 
開發者ID:war-and-code,項目名稱:jawfish,代碼行數:10,代碼來源:test_result.py

示例7: testGetDescriptionWithMultiLineDocstring

# 需要導入模塊: import unittest [as 別名]
# 或者: from unittest import TextTestResult [as 別名]
def testGetDescriptionWithMultiLineDocstring(self):
        """Tests getDescription() for a method with a longer docstring.
        The second line of the docstring.
        """
        result = unittest.TextTestResult(None, True, 1)
        self.assertEqual(
                result.getDescription(self),
               ('testGetDescriptionWithMultiLineDocstring '
                '(' + __name__ + '.Test_TestResult)\n'
                'Tests getDescription() for a method with a longer '
                'docstring.')) 
開發者ID:war-and-code,項目名稱:jawfish,代碼行數:13,代碼來源:test_result.py

示例8: test_init

# 需要導入模塊: import unittest [as 別名]
# 或者: from unittest import TextTestResult [as 別名]
def test_init(self):
        runner = unittest.TextTestRunner()
        self.assertFalse(runner.failfast)
        self.assertFalse(runner.buffer)
        self.assertEqual(runner.verbosity, 1)
        self.assertTrue(runner.descriptions)
        self.assertEqual(runner.resultclass, unittest.TextTestResult) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:9,代碼來源:test_runner.py

示例9: test_multiple_inheritance

# 需要導入模塊: import unittest [as 別名]
# 或者: from unittest import TextTestResult [as 別名]
def test_multiple_inheritance(self):
        class AResult(unittest.TestResult):
            def __init__(self, stream, descriptions, verbosity):
                super(AResult, self).__init__(stream, descriptions, verbosity)

        class ATextResult(unittest.TextTestResult, AResult):
            pass

        # This used to raise an exception due to TextTestResult not passing
        # on arguments in its __init__ super call
        ATextResult(None, None, 1) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:13,代碼來源:test_runner.py

示例10: test_multiple_inheritance

# 需要導入模塊: import unittest [as 別名]
# 或者: from unittest import TextTestResult [as 別名]
def test_multiple_inheritance(self):
        class AResult(unittest.TestResult):
            def __init__(self, stream, descriptions, verbosity):
                super(AResult, self).__init__(stream, descriptions, verbosity)

        class ATextResult(unittest.TextTestResult, AResult):
            pass

        # This used to raise an exception due to TextTestResult not passing
        # on arguments in its __init__ super call
        ATextResult(None, None, None) 
開發者ID:dxwu,項目名稱:BinderFilter,代碼行數:13,代碼來源:test_runner.py

示例11: addSuccess

# 需要導入模塊: import unittest [as 別名]
# 或者: from unittest import TextTestResult [as 別名]
def addSuccess(self, test):
        super(TextTestResult, self).addSuccess(test)
        self._process(test, "ok") 
開發者ID:refack,項目名稱:GYP3,代碼行數:5,代碼來源:taprunner.py

示例12: addFailure

# 需要導入模塊: import unittest [as 別名]
# 或者: from unittest import TextTestResult [as 別名]
def addFailure(self, test, err):
        super(TextTestResult, self).addFailure(test, err)
        self._process(test, "not ok", "FAIL")
        # [ ] add structured data about assertion 
開發者ID:refack,項目名稱:GYP3,代碼行數:6,代碼來源:taprunner.py

示例13: addError

# 需要導入模塊: import unittest [as 別名]
# 或者: from unittest import TextTestResult [as 別名]
def addError(self, test, err):
        super(TextTestResult, self).addError(test, err)
        self._process(test, "not ok", "ERROR")
        # [ ] add structured data about exception 
開發者ID:refack,項目名稱:GYP3,代碼行數:6,代碼來源:taprunner.py

示例14: addSkip

# 需要導入模塊: import unittest [as 別名]
# 或者: from unittest import TextTestResult [as 別名]
def addSkip(self, test, reason):
        super(TextTestResult, self).addSkip(test, reason)
        self._process(test, "ok", directive=("  # SKIP  %s" % reason)) 
開發者ID:refack,項目名稱:GYP3,代碼行數:5,代碼來源:taprunner.py

示例15: addExpectedFailure

# 需要導入模塊: import unittest [as 別名]
# 或者: from unittest import TextTestResult [as 別名]
def addExpectedFailure(self, test, err):
        super(TextTestResult, self).addExpectedFailure(test, err)
        self._process(test, "not ok", directive=("  # TODO")) 
開發者ID:refack,項目名稱:GYP3,代碼行數:5,代碼來源:taprunner.py


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