You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
assert cucumbers['start'] - cucumbers['eat'] == left
274
273
275
274
Example code also shows possibility to pass argument converters which may be useful if you need to postprocess step
276
275
arguments after the parser.
@@ -303,21 +302,11 @@ You can implement your own step parser. It's interface is quite simple. The code
303
302
returnbool(self.regex.match(name))
304
303
305
304
306
-
@given(parsers.parse("there are %start% cucumbers"), target_fixture="start_cucumbers")
307
-
defstart_cucumbers(start):
305
+
@given(parsers.parse("there are %start% cucumbers"), target_fixture="cucumbers")
306
+
defgiven_cucumbers(start):
308
307
returndict(start=start, eat=0)
309
308
310
309
311
-
Step arguments are fixtures as well!
312
-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
313
-
314
-
Step arguments are injected into pytest `request` context as normal fixtures with the names equal to the names of the
315
-
arguments. This opens a number of possibilities:
316
-
317
-
* you can access step's argument as a fixture in other step function just by mentioning it as an argument (just like any other pytest fixture)
318
-
* if the name of the step argument clashes with existing fixture, it will be overridden by step's argument value; this way you can set/override the value for some fixture deeply inside of the fixture tree in a ad-hoc way by just choosing the proper name for the step argument.
0 commit comments