tests.py 文件源码

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

项目:gmailtool 作者: adamandpaul 项目源码 文件源码
def test_suite(package_name='gmailtool', pattern='*_test.py'):
    """Create the test suite used for the test runer

    Discover tests and load them into a test suite.

    Args:
        package_name (str): The package we are interested in loading a test suite for
        pattern (str): The glob patten used for test discovery

    Returns:
        TestSuite: The test suite to be used for the test runner
    """

    # The egg info object is needed to get the top_level_dir value
    environment = pkg_resources.Environment()
    assert len(environment[package_name]), 'we should only have a single environment to deal with'
    this_egg_info = environment[package_name][0]

    # Find the top_level_dir, because namespaces don't work too good with unittest
    top_level_dir = this_egg_info.location

    test_loader = unittest.TestLoader()
    suite = test_loader.discover(package_name,
                                 pattern=pattern,
                                 top_level_dir=top_level_dir)
    return suite
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号