feat: use scenarios() shortcut in code generation template#796
feat: use scenarios() shortcut in code generation template#796toroleapinc wants to merge 3 commits intopytest-dev:masterfrom
Conversation
Replace individual @Scenario() decorators with the scenarios() shortcut function in the code generation template. This produces cleaner, more concise generated test code. Before: @Scenario('feature.feature', 'Scenario 1') def test_scenario_1(): ... @Scenario('feature.feature', 'Scenario 2') def test_scenario_2(): ... After: scenarios('feature.feature') Closes pytest-dev#535 Signed-off-by: edvatar <88481784+toroleapinc@users.noreply.github.com>
| @@ -1,22 +1,22 @@ | |||
| <% | |||
| feature_paths = sorted(set(s.feature.rel_filename for s in scenarios)) | |||
There was a problem hiding this comment.
- Shouldn't we use the
featurescar instead ofscenarios?
There was a problem hiding this comment.
Good catch, updated to use features directly.
| <% | ||
| feature_paths = sorted(set(f.rel_filename for f in features)) | ||
| %>\ |
There was a problem hiding this comment.
this should go right before line 14
The template now emits a single scenarios('foo.feature') call instead
of one @Scenario(...) decorator per scenario, so the expected output
strings in test_generate, test_generate_with_quotes, and
test_unicode_characters need to match.
|
Pushed ed581b5 — updated the expected output strings in Looks like the CI run is currently blocked on |
Summary
Update the code generation template to use the
scenarios()shortcut instead of individual@scenario()decorators.Closes #535
Changes
Modified
src/pytest_bdd/templates/test.py.makto:scenariosinstead ofscenarioscenarios('feature_file.feature')calls instead of individual@scenario(...)decorated test functionsBefore
After