diff --git a/src/pytest_bdd/templates/test.py.mak b/src/pytest_bdd/templates/test.py.mak index 9f7901539..f351b039a 100644 --- a/src/pytest_bdd/templates/test.py.mak +++ b/src/pytest_bdd/templates/test.py.mak @@ -1,22 +1,22 @@ +<% + feature_paths = sorted(set(s.feature.rel_filename for s in scenarios)) +%>\ % if features: """${ features[0].name or features[0].rel_filename } feature tests.""" from pytest_bdd import ( given, - scenario, + scenarios, then, when, ) - -% endif -% for scenario in sorted(scenarios, key=lambda scenario: scenario.name): -@scenario('${scenario.feature.rel_filename}', ${ make_string_literal(scenario.name)}) -def test_${ make_python_name(scenario.name)}(): - ${make_python_docstring(scenario.name)} +% for feature_path in feature_paths: +scenarios('${feature_path}') +% endfor -% endfor +% endif % for step in steps: @${step.type}(${ make_string_literal(step.name)}) def _():