解析Python的Behave BDD中的步骤的列表参数

时间:2017-08-09 12:02:26

标签: python pycharm bdd

我可以在“解析”模块中使用预定义数据类型来解析“cfparse”列表参数吗?

我在PyCharm 2017中使用了1.2.6.dev0。 .feature是:

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        |

步骤文件是

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

此处{directions +}应为字符串列表,“+”表示1 .. *基数。 'n'是“解析模块”中预定义的数字类型。 (来自https://pythonhosted.org/behave/tutorial.htmlhttps://jenisys.github.io/behave.example/datatype/builtin_types.html

我收到错误:     ...     在extract_format中的文件“... / python3.6 / site-packages / parse.py”,第614行     引发ValueError('格式规范%r未识别'%type)     ValueError:格式规范'n +'无法识别

有没有办法重用预定义的类型?或者我是否需要为字符串列表,整数列表等编写用户定义的类型?

0 个答案:

没有答案