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)
评论列表
文章目录