Parsing list arguments to steps in Python's Behave BDD

Viewed 2815

Can I use predefined data types in "parse" module for parsing list arguments by "cfparse"?

I'm using behave 1.2.6.dev0 in PyCharm 2017.2. The .feature is:

Scenario Outline:

Given Drone flies <directions> for <distances> meters
Then it will be <distance> meters from launchpad
Examples:
  | directions | distances | distance |
  |North, West | 3, 4      | 5        |

The steps file is

from behave import *
use_step_matcher("cfparse")

@given("Drone flies {directions+} for {distances:n+} meters")
def step_impl(context, directions, distances):
pass 

@then("it will be {distance:n} meters from launchpad")
def step_impl(context, distance):
pass

Here {directions+} should be a list of strings, with "+" implying 1..* cardinality. The 'n' is the pre-defined number type in "parse module". (From https://pythonhosted.org/behave/tutorial.html and https://jenisys.github.io/behave.example/datatype/builtin_types.html)

I get the error: ... File ".../python3.6/site-packages/parse.py", line 614, in extract_format raise ValueError('format spec %r not recognised' % type) ValueError: format spec 'n+' not recognised

Is there a way to reuse the predefined types? Or do I need to write user-defined types for List of strings, List of ints, etc?

0 Answers
Related