当前位置: 首页>>代码示例>>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;未经允许,请勿转载。