Skip to content

Commit f955634

Browse files
committed
Avoid pytest.mark.usefixtures call without arguments
This will raise a warning in an upcoming change in pytest
1 parent 93e446e commit f955634

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/pytest_bdd/scenario.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,16 +271,18 @@ def decorator(*args: Callable[P, T]) -> Callable[P, T]:
271271
[fn] = args
272272
func_args = get_args(fn)
273273

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)
277274
def scenario_wrapper(request: FixtureRequest, _pytest_bdd_example: dict[str, str]) -> Any:
278275
__tracebackhide__ = True
279276
scenario = templated_scenario.render(_pytest_bdd_example)
280277
_execute_scenario(feature, scenario, request)
281278
fixture_values = [request.getfixturevalue(arg) for arg in func_args]
282279
return fn(*fixture_values)
283280

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+
284286
example_parametrizations = collect_example_parametrizations(templated_scenario)
285287
if example_parametrizations is not None:
286288
# Parametrize the scenario outlines

0 commit comments

Comments
 (0)