MCPcopy Create free account
hub / github.com/pytest-dev/pytest-bdd / get_step_function

Function get_step_function

src/pytest_bdd/scenario.py:159–176  ·  view source on GitHub ↗

Get the step function (context) for the given step. We first figure out what's the step fixture name that we have to inject. Then we let `patch_argumented_step_functions` find out what step definition fixtures can parse the current step, and it will inject them for the step fixture nam

(request: FixtureRequest, step: Step)

Source from the content-addressed store, hash-verified

157
158
159def get_step_function(request: FixtureRequest, step: Step) -> StepFunctionContext | None:
160 """Get the step function (context) for the given step.
161
162 We first figure out what's the step fixture name that we have to inject.
163
164 Then we let `patch_argumented_step_functions` find out what step definition fixtures can parse the current step,
165 and it will inject them for the step fixture name.
166
167 Finally, we let request.getfixturevalue(...) fetch the step definition fixture.
168 """
169 __tracebackhide__ = True
170 bdd_name = get_step_fixture_name(step=step)
171
172 with inject_fixturedefs_for_step(step=step, fixturemanager=request._fixturemanager, node=request.node):
173 try:
174 return cast(StepFunctionContext, request.getfixturevalue(bdd_name))
175 except pytest.FixtureLookupError:
176 return None
177
178
179def parse_step_arguments(step: Step, context: StepFunctionContext) -> dict[str, object]:

Callers 1

_execute_scenarioFunction · 0.85

Calls 2

get_step_fixture_nameFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…