本文整理汇总了Python中tests.test_classes方法的典型用法代码示例。如果您正苦于以下问题:Python tests.test_classes方法的具体用法?Python tests.test_classes怎么用?Python tests.test_classes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tests
的用法示例。
在下文中一共展示了tests.test_classes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: import tests [as 别名]
# 或者: from tests import test_classes [as 别名]
def run(matcher=None, repeat=1, ci=False):
"""
Runs the tests
:param matcher:
A unicode string containing a regular expression to use to filter test
names by. A value of None will cause no filtering.
:param repeat:
An integer - the number of times to run the tests
:param ci:
A bool, indicating if the tests are being run as part of CI
:return:
A bool - if the tests succeeded
"""
_preload(requires_oscrypto, not ci)
warnings.filterwarnings("error")
loader = unittest.TestLoader()
# We have to manually track the list of applicable tests because for
# some reason with Python 3.4 on Windows, the tests in a suite are replaced
# with None after being executed. This breaks the repeat functionality.
test_list = []
for test_class in test_classes():
if matcher:
names = loader.getTestCaseNames(test_class)
for name in names:
if re.search(matcher, name):
test_list.append(test_class(name))
else:
test_list.append(loader.loadTestsFromTestCase(test_class))
stream = sys.stdout
verbosity = 1
if matcher and repeat == 1:
verbosity = 2
elif repeat > 1:
stream = StringIO()
for _ in range(0, repeat):
suite = unittest.TestSuite()
for test in test_list:
suite.addTest(test)
result = unittest.TextTestRunner(stream=stream, verbosity=verbosity).run(suite)
if len(result.errors) > 0 or len(result.failures) > 0:
if repeat > 1:
print(stream.getvalue())
return False
if repeat > 1:
stream.truncate(0)
return True