discover_tests.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:packaging 作者: blockstack 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号