@@ -271,16 +271,18 @@ def decorator(*args: Callable[P, T]) -> Callable[P, T]:
271
271
[fn ] = args
272
272
func_args = get_args (fn )
273
273
274
- # We need to tell pytest that the original function requires its fixtures,
275
- # otherwise indirect fixtures would not work.
276
- @pytest .mark .usefixtures (* func_args )
277
274
def scenario_wrapper (request : FixtureRequest , _pytest_bdd_example : dict [str , str ]) -> Any :
278
275
__tracebackhide__ = True
279
276
scenario = templated_scenario .render (_pytest_bdd_example )
280
277
_execute_scenario (feature , scenario , request )
281
278
fixture_values = [request .getfixturevalue (arg ) for arg in func_args ]
282
279
return fn (* fixture_values )
283
280
281
+ if func_args :
282
+ # We need to tell pytest that the original function requires its fixtures,
283
+ # otherwise indirect fixtures would not work.
284
+ scenario_wrapper = pytest .mark .usefixtures (* func_args )(scenario_wrapper )
285
+
284
286
example_parametrizations = collect_example_parametrizations (templated_scenario )
285
287
if example_parametrizations is not None :
286
288
# Parametrize the scenario outlines
@@ -295,7 +297,7 @@ def scenario_wrapper(request: FixtureRequest, _pytest_bdd_example: dict[str, str
295
297
config .hook .pytest_bdd_apply_tag (tag = tag , function = scenario_wrapper )
296
298
297
299
scenario_wrapper .__doc__ = f"{ feature_name } : { scenario_name } "
298
- scenario_wrapper .__scenario__ = templated_scenario
300
+ scenario_wrapper .__scenario__ = templated_scenario # type: ignore[attr-defined]
299
301
return cast (Callable [P , T ], scenario_wrapper )
300
302
301
303
return decorator
0 commit comments