本文整理汇总了Python中unittest.TestLoader.countTestCases方法的典型用法代码示例。如果您正苦于以下问题:Python TestLoader.countTestCases方法的具体用法?Python TestLoader.countTestCases怎么用?Python TestLoader.countTestCases使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unittest.TestLoader
的用法示例。
在下文中一共展示了TestLoader.countTestCases方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from unittest import TestLoader [as 别名]
# 或者: from unittest.TestLoader import countTestCases [as 别名]
def run(self):
"""
Finds and executes unit tests in the 'tests' subdir.
Because TestLoader imports the tests as a module this method
automatically creates/updates the 'tests/__init__.py' to
import all python scripts in the 'tests' subdir.
"""
self.run_command('build')
sys.path.insert(0,os.path.join(os.getcwd(),"build","lib"))
self.tests = []
# make sure the 'tests' subdir actually exists.
if not os.path.isdir(self.tests_dir):
print "ExecuteTests: <Error> 'tests' subdir not found!"
else:
self.find_tests()
self.gen_tests_init()
# create a test suite.
tests = TestLoader().loadTestsFromNames([t[0] for t in self.tests])
if not self.filter is None:
tests = self.filter_tests(tests)
# run the test suite if it actually contains test cases.
run_verbosity = 2
if self.verbose == 0:
run_verbosity = 0
if tests.countTestCases() > 0:
runner = TextTestRunner(verbosity=run_verbosity)
runner.run(tests)
else:
print "ExecuteTests: <Warning> No test cases found!"
sys.path.pop(0)
示例2: TestLoader
# 需要导入模块: from unittest import TestLoader [as 别名]
# 或者: from unittest.TestLoader import countTestCases [as 别名]
#!/usr/bin/env python3
from unittest import TestLoader
if __name__ == '__main__':
runner = TestLoader().discover('tests')
print('Running {} tests...'.format(runner.countTestCases()))
runner.debug()
print('All tests passed.')