Execute step function.
(
request: FixtureRequest, scenario: Scenario, step: Step, context: StepFunctionContext
)
| 198 | |
| 199 | |
| 200 | def _execute_step_function( |
| 201 | request: FixtureRequest, scenario: Scenario, step: Step, context: StepFunctionContext |
| 202 | ) -> None: |
| 203 | """Execute step function.""" |
| 204 | __tracebackhide__ = True |
| 205 | |
| 206 | func_sig = signature(context.step_func) |
| 207 | |
| 208 | kw = { |
| 209 | "request": request, |
| 210 | "feature": scenario.feature, |
| 211 | "scenario": scenario, |
| 212 | "step": step, |
| 213 | "step_func": context.step_func, |
| 214 | "step_func_args": {}, |
| 215 | } |
| 216 | request.config.hook.pytest_bdd_before_step(**kw) |
| 217 | |
| 218 | try: |
| 219 | parsed_args = parse_step_arguments(step=step, context=context) |
| 220 | |
| 221 | # Filter out the arguments that are not in the function signature |
| 222 | kwargs = {k: v for k, v in parsed_args.items() if k in func_sig.parameters} |
| 223 | |
| 224 | if STEP_ARGUMENT_DATATABLE in func_sig.parameters and step.datatable is not None: |
| 225 | kwargs[STEP_ARGUMENT_DATATABLE] = step.datatable.raw() |
| 226 | if STEP_ARGUMENT_DOCSTRING in func_sig.parameters and step.docstring is not None: |
| 227 | kwargs[STEP_ARGUMENT_DOCSTRING] = step.docstring |
| 228 | |
| 229 | # Fill the missing arguments requesting the fixture values |
| 230 | kwargs |= { |
| 231 | arg: request.getfixturevalue(arg) for arg in get_required_args(context.step_func) if arg not in kwargs |
| 232 | } |
| 233 | |
| 234 | kw["step_func_args"] = kwargs |
| 235 | |
| 236 | request.config.hook.pytest_bdd_before_step_call(**kw) |
| 237 | |
| 238 | # Execute the step as if it was a pytest fixture using `call_fixture_func`, |
| 239 | # so that we can allow "yield" statements in it |
| 240 | return_value = call_fixture_func(fixturefunc=context.step_func, request=request, kwargs=kwargs) |
| 241 | |
| 242 | except Exception as exception: |
| 243 | request.config.hook.pytest_bdd_step_error(exception=exception, **kw) |
| 244 | raise |
| 245 | |
| 246 | if context.target_fixture is not None: |
| 247 | inject_fixture(request, context.target_fixture, return_value) |
| 248 | |
| 249 | request.config.hook.pytest_bdd_after_step(**kw) |
| 250 | |
| 251 | |
| 252 | def _execute_scenario(feature: Feature, scenario: Scenario, request: FixtureRequest) -> None: |
no test coverage detected
searching dependent graphs…