Skip to content

Commit 39f7297

Browse files
youtuxolegpidsadnyi
authored andcommitted
Defer fixture wrapping of lazy_step_function
This will ensure that we attach parser and converters to the actual function that pytest will discover when collecting fixtures.
1 parent fb28403 commit 39f7297

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

pytest_bdd/steps.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,15 +172,10 @@ def step_func(request):
172172

173173
step_func.__name__ = force_encode(parsed_step_name)
174174

175-
@pytest.fixture(scope=scope)
176175
def lazy_step_func():
177176
return step_func
178177

179178
step_func.step_type = step_type
180-
181-
lazy_step_func = contribute_to_module(
182-
get_caller_module(), get_step_fixture_name(parsed_step_name, step_type), lazy_step_func)
183-
184179
lazy_step_func.step_type = step_type
185180

186181
# Preserve the docstring
@@ -190,6 +185,13 @@ def lazy_step_func():
190185
if converters:
191186
step_func.converters = lazy_step_func.converters = converters
192187

188+
lazy_step_func = pytest.fixture(scope=scope)(lazy_step_func)
189+
contribute_to_module(
190+
module=get_caller_module(),
191+
name=get_step_fixture_name(parsed_step_name, step_type),
192+
func=lazy_step_func,
193+
)
194+
193195
return func
194196

195197
return decorator

0 commit comments

Comments
 (0)