场景大纲:Blah de blah 当我输入并在输入字段上时 那么一切都很好
例子:
|一个 | b |
| 1 | 2 |
| | 3 |
上述场景在 BBD Behave 中抛出以下错误 测试未定义 请定义测试
我不确定如何解决这个问题。 有什么建议么?
最佳答案
使用 https://pypi.org/project/parse/
中描述的自定义类型转换
import parse
from behave import given, register_type
@parse.with_pattern(r'.*')
def parse_nullable_string(text):
return text
register_type(NullableString=parse_nullable_string)
@given('params "{a:NullableString}" and "{b:NullableString}"'
def set_params(context, a, b):
# a or b will be empty if they are blank in the Examples
context.a = a
context.b = b
现在特征文件看起来像这样,
Given params "<a>" and "<b>"
# Rest of the steps
Examples:
| a | b |
| 1 | 2 |
| | 3 |
关于python - 是否可以有一个空值的场景大纲表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29298550/