def pytest_collection_modifyitems(config, items):
"""Hook to detect forbidden calls inside test."""
if config.option.disable_steps_checker:
config.warn('P1', 'Permitted calls checker is disabled!')
return
errors = []
for item in items:
permitted_calls = PERMITTED_CALLS + STEPS + item.funcargnames
validator = TestValidator(item.function, permitted_calls)
errors.extend(validator.validate())
if errors:
pytest.exit("Only steps and fixtures must be called in test!\n" +
'\n'.join(errors))
评论列表
文章目录