本文整理汇总了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)
示例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
示例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)
示例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)
示例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)')
示例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.'))
示例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.'))
示例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)
示例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)
示例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)
示例11: addSuccess
# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import TextTestResult [as 别名]
def addSuccess(self, test):
super(TextTestResult, self).addSuccess(test)
self._process(test, "ok")
示例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
示例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
示例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))
示例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"))