plugin.py 文件源码

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

项目:pytest-random-order 作者: jbasko 项目源码 文件源码
def pytest_collection_modifyitems(session, config, items):
    failure = None

    item_ids = _get_set_of_item_ids(items)

    try:
        seed = getattr(config, 'random_order_seed', None)
        bucket_type = config.getoption('random_order_bucket')
        _shuffle_items(items, bucket_key=_random_order_item_keys[bucket_type], disable=_disable, seed=seed)

    except Exception as e:
        # See the finally block -- we only fail if we have lost user's tests.
        _, _, exc_tb = sys.exc_info()
        failure = 'pytest-random-order plugin has failed with {0!r}:\n{1}'.format(
            e, ''.join(traceback.format_tb(exc_tb, 10))
        )
        config.warn(0, failure, None)

    finally:
        # Fail only if we have lost user's tests
        if item_ids != _get_set_of_item_ids(items):
            if not failure:
                failure = 'pytest-random-order plugin has failed miserably'
            raise RuntimeError(failure)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号