gpt4 book ai didi

python - 在 behave 中的步骤之间传递参数

转载 作者:行者123 更新时间:2023-11-28 21:23:17 27 4
gpt4 key购买 nike

我有多个示例的场景大纲,如下所示:

 Examples:
| country | type | number |
| Poland | An individual | - |
| Poland | Company | 8971660890 |
| Germany | An individual | - |
| France | Company | 92511490856 |

我想使用此示例并将其传递给步骤定义之一以创建条件表达式,例如:

@step(check_sth)
def step_imp(country, type, number):
if county == Poland:
do sth
elif type == individual:
do other thing

在巴哈维有可能吗?

最佳答案

有关如何执行此操作的行为教程:https://pythonhosted.org/behave/tutorial.html

特别是,看看如何设置场景大纲,例如:

    Given I enter the following data <country> <type> and <number>,
Then check that <country> is correct

将为您提供以下步骤定义:

    @given('I enter the following data "{country}" "{type}" and "{number}",')
def step_impl(context, country, type, number):

@then('check that "{country}" is correct')
def step_impl(context, country):

关于python - 在 behave 中的步骤之间传递参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46663098/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com