本文整理汇总了Python中unittest.case.TestCase方法的典型用法代码示例。如果您正苦于以下问题:Python case.TestCase方法的具体用法?Python case.TestCase怎么用?Python case.TestCase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unittest.case
的用法示例。
在下文中一共展示了case.TestCase方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: addSuccess
# 需要导入模块: from unittest import case [as 别名]
# 或者: from unittest.case import TestCase [as 别名]
def addSuccess(self, test: TestCase):
super().addSuccess(test)
self.stream.writeln('## Ending Test ##')
self.passed.append((test, ''))
logger = getLogger('djongo')
logger.setLevel(INFO)
示例2: test_retry_without_arg
# 需要导入模块: from unittest import case [as 别名]
# 或者: from unittest.case import TestCase [as 别名]
def test_retry_without_arg(self):
# Check docstrings of decorated functions.
def func(*args):
"""func docstring"""
return 1
def func_raises(exc=Exception):
"""func_raises docstring"""
raise exc
self.assertEqual(retry(func).__doc__, func.__doc__)
self.assertEqual(retry()(func).__doc__, func.__doc__)
self.assertEqual(retry(func_raises).__doc__, func_raises.__doc__)
self.assertEqual(retry()(func_raises).__doc__, func_raises.__doc__)
# Check func returns correctly after it is decorated.
self.assertEqual(retry(func)(), 1)
self.assertEqual(retry()(func)(), 1)
# Check func raises correctly after it is decorated.
with self.assertRaises(Exception):
retry(func_raises, wait=0)()
with self.assertRaises(Exception):
retry(wait=0)(func_raises)()
with self.assertRaises(NotImplementedError):
retry(func_raises, wait=0)(NotImplementedError)
with self.assertRaises(NotImplementedError):
retry(wait=0)(func_raises)(NotImplementedError)
with self.assertRaises(NotImplementedError):
retry(func_raises, wait=0, max_attempts=0)(NotImplementedError)
with self.assertRaises(NotImplementedError):
retry(wait=0, max_attempts=0)(func_raises)(NotImplementedError)
# Check TypeError is raised if args have incorrect values.
with self.assertRaises(TypeError):
retry(max_attempts="") # needs to be an int
with self.assertRaises(TypeError):
retry(exc=TestCase) # need to be subclass of Exception (single value)
with self.assertRaises(TypeError):
retry(exc=(TestCase,)) # need to be subclass of Exception (tuple)
with self.assertRaises(TypeError):
retry(wait="") # needs to be a float