本文整理汇总了Python中unittest2.TextTestResult方法的典型用法代码示例。如果您正苦于以下问题:Python unittest2.TextTestResult方法的具体用法?Python unittest2.TextTestResult怎么用?Python unittest2.TextTestResult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unittest2
的用法示例。
在下文中一共展示了unittest2.TextTestResult方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_tracebacks
# 需要导入模块: import unittest2 [as 别名]
# 或者: from unittest2 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)
示例2: test_init
# 需要导入模块: import unittest2 [as 别名]
# 或者: from unittest2 import TextTestResult [as 别名]
def test_init(self):
runner = unittest2.TextTestRunner()
self.assertFalse(runner.failfast)
self.assertFalse(runner.buffer)
self.assertEqual(runner.verbosity, 1)
self.assertTrue(runner.descriptions)
self.assertEqual(runner.resultclass, unittest2.TextTestResult)
示例3: testInheritance
# 需要导入模块: import unittest2 [as 别名]
# 或者: from unittest2 import TextTestResult [as 别名]
def testInheritance(self):
self.assertIsSubclass(unittest2.TestCase, unittest.TestCase)
self.assertIsSubclass(unittest2.TestResult, unittest.TestResult)
self.assertIsSubclass(unittest2.TestSuite, unittest.TestSuite)
self.assertIsSubclass(unittest2.TextTestRunner, unittest.TextTestRunner)
self.assertIsSubclass(unittest2.TestLoader, unittest.TestLoader)
self.assertIsSubclass(unittest2.TextTestResult, unittest.TestResult)
示例4: testGetDescriptionWithoutDocstring
# 需要导入模块: import unittest2 [as 别名]
# 或者: from unittest2 import TextTestResult [as 别名]
def testGetDescriptionWithoutDocstring(self):
result = unittest2.TextTestResult(None, True, 1)
self.assertEqual(
result.getDescription(self),
'testGetDescriptionWithoutDocstring (' + __name__ +
'.Test_TestResult)')
示例5: testGetDescriptionWithOneLineDocstring
# 需要导入模块: import unittest2 [as 别名]
# 或者: from unittest2 import TextTestResult [as 别名]
def testGetDescriptionWithOneLineDocstring(self):
"""Tests getDescription() for a method with a docstring."""
result = unittest2.TextTestResult(None, True, 1)
self.assertEqual(
result.getDescription(self),
('testGetDescriptionWithOneLineDocstring '
'(' + __name__ + '.Test_TestResult)\n'
'Tests getDescription() for a method with a docstring.'))
示例6: testGetDescriptionWithMultiLineDocstring
# 需要导入模块: import unittest2 [as 别名]
# 或者: from unittest2 import TextTestResult [as 别名]
def testGetDescriptionWithMultiLineDocstring(self):
"""Tests getDescription() for a method with a longer docstring.
The second line of the docstring.
"""
result = unittest2.TextTestResult(None, True, 1)
self.assertEqual(
result.getDescription(self),
('testGetDescriptionWithMultiLineDocstring '
'(' + __name__ + '.Test_TestResult)\n'
'Tests getDescription() for a method with a longer '
'docstring.'))