@@ -161,32 +161,24 @@ def test_angular_brackets_are_not_parsed(pytester):
161
161
"""
162
162
pytester .makefile (
163
163
".feature" ,
164
- simple = '''
164
+ simple = """
165
165
Feature: Simple feature
166
166
Scenario: Simple scenario
167
167
Given I have a <tag>
168
168
Then pass
169
169
170
170
Scenario Outline: Outlined scenario
171
171
Given I have a templated <foo>
172
- When I have a templated datatable
173
- | <data> |
174
- | example |
175
- And I have a templated docstring
176
- """
177
- This is a <doc>
178
- """
179
172
Then pass
180
173
181
174
Examples:
182
- | foo | data | doc |
183
- | bar | table | string |
184
- ''' ,
175
+ | foo |
176
+ | bar |
177
+ """ ,
185
178
)
186
179
pytester .makepyfile (
187
180
"""
188
- from pytest_bdd import scenarios, given, when, then, parsers
189
- from pytest_bdd.utils import dump_obj
181
+ from pytest_bdd import scenarios, given, then, parsers
190
182
191
183
scenarios("simple.feature")
192
184
@@ -198,23 +190,97 @@ def _():
198
190
def _(foo):
199
191
return "foo"
200
192
193
+ @then("pass")
194
+ def _():
195
+ pass
196
+ """
197
+ )
198
+ result = pytester .runpytest ()
199
+ result .assert_outcomes (passed = 2 )
200
+
201
+
202
+ def test_example_params (pytester ):
203
+ """Test example params are rendered where necessary:
204
+ * Step names
205
+ * Docstring
206
+ * Datatables
207
+ """
208
+ pytester .makefile (
209
+ ".feature" ,
210
+ example_params = '''
211
+ Feature: Example params
212
+ Background:
213
+ Given I have a background <background>
214
+ And my background has:
215
+ """
216
+ Background <background>
217
+ """
218
+
219
+ Scenario Outline: Outlined scenario
220
+ Given I have a templated <foo>
221
+ When I have a templated datatable
222
+ | <data> |
223
+ | example |
224
+ And I have a templated docstring
225
+ """
226
+ This is a <doc>
227
+ """
228
+ Then pass
229
+
230
+ Examples:
231
+ | background | foo | data | doc |
232
+ | parameter | bar | table | string |
233
+ ''' ,
234
+ )
235
+ pytester .makepyfile (
236
+ """
237
+ from pytest_bdd import scenarios, given, when, then, parsers
238
+ from pytest_bdd.utils import dump_obj
239
+
240
+ scenarios("example_params.feature")
241
+
242
+
243
+ @given(parsers.parse("I have a background {background}"))
244
+ def _(background):
245
+ return dump_obj(("background", background))
246
+
247
+
248
+ @given(parsers.parse("I have a templated {foo}"))
249
+ def _(foo):
250
+ return "foo"
251
+
252
+
253
+ @given("my background has:")
254
+ def _(docstring):
255
+ return dump_obj(("background_docstring", docstring))
256
+
257
+
258
+ @given("I have a rule table:")
259
+ def _(datatable):
260
+ return dump_obj(("rule", datatable))
261
+
262
+
201
263
@when("I have a templated datatable")
202
264
def _(datatable):
203
265
return dump_obj(("datatable", datatable))
204
266
267
+
205
268
@when("I have a templated docstring")
206
269
def _(docstring):
207
270
return dump_obj(("docstring", docstring))
208
271
272
+
209
273
@then("pass")
210
274
def _():
211
275
pass
212
276
"""
213
277
)
214
278
result = pytester .runpytest ("-s" )
215
- result .assert_outcomes (passed = 2 )
279
+ result .assert_outcomes (passed = 1 )
216
280
217
281
assert collect_dumped_objects (result ) == [
282
+ ("background" , "parameter" ),
283
+ ("background_docstring" , "Background parameter" ),
218
284
("datatable" , [["table" ], ["example" ]]),
219
285
("docstring" , "This is a string" ),
220
286
]
0 commit comments