def exclude_tests(suite, blacklist):
"""
Example:
blacklist = [
'test_some_test_that_should_be_skipped',
'test_another_test_that_should_be_skipped'
]
"""
new_suite = unittest.TestSuite()
for test_group in suite._tests:
for test in test_group:
if not hasattr(test, '_tests'):
# e.g. ModuleImportFailure
new_suite.addTest(test)
continue
for subtest in test._tests:
method = subtest._testMethodName
if method in blacklist:
setattr(test,
method,
getattr(SkipCase(), 'skeleton_run_test'))
new_suite.addTest(test)
return new_suite
评论列表
文章目录