call after scenario hook after all steps

This commit is contained in:
Sherzod Karimov 2022-11-07 16:29:10 -05:00
parent 780a6777e9
commit ec243313c8
1 changed files with 14 additions and 15 deletions

View File

@ -178,22 +178,21 @@ def _execute_scenario(feature: Feature, scenario: Scenario, request: FixtureRequ
__tracebackhide__ = True __tracebackhide__ = True
request.config.hook.pytest_bdd_before_scenario(request=request, feature=feature, scenario=scenario) request.config.hook.pytest_bdd_before_scenario(request=request, feature=feature, scenario=scenario)
for step in scenario.steps: try:
step_func_context = get_step_function(request=request, step=step) for step in scenario.steps:
if step_func_context is None: step_func_context = get_step_function(request=request, step=step)
exc = exceptions.StepDefinitionNotFoundError( if step_func_context is None:
f"Step definition is not found: {step}. " exc = exceptions.StepDefinitionNotFoundError(
f'Line {step.line_number} in scenario "{scenario.name}" in the feature "{scenario.feature.filename}"' f"Step definition is not found: {step}. "
) f'Line {step.line_number} in scenario "{scenario.name}" in the feature "{scenario.feature.filename}"'
request.config.hook.pytest_bdd_step_func_lookup_error( )
request=request, feature=feature, scenario=scenario, step=step, exception=exc request.config.hook.pytest_bdd_step_func_lookup_error(
) request=request, feature=feature, scenario=scenario, step=step, exception=exc
raise exc )
raise exc
try:
_execute_step_function(request, scenario, step, step_func_context) _execute_step_function(request, scenario, step, step_func_context)
finally: finally:
request.config.hook.pytest_bdd_after_scenario(request=request, feature=feature, scenario=scenario) request.config.hook.pytest_bdd_after_scenario(request=request, feature=feature, scenario=scenario)
def _get_scenario_decorator( def _get_scenario_decorator(