【发布时间】:2016-01-10 21:14:38
【问题描述】:
如何在 pytest bdd 中将参数从 WHEN 传递到 THEN?
例如,如果我有以下代码:
@when('<n1> is a number divisible by 10')
def n1_is_a_number_divisible_by_10(n1):
assert (n1 % 10) == 0
newN1 = n1/10
return newN1
@then('the result will also be divisible by 3')
def the_result_will_also_be_divisible_by_3(newN1):
assert newN1 % 3 == 0
如何将 newN1 从 when 传递到 then?
(我曾尝试将 newN1 设为全局变量...这可行,但在 python 中通常不赞成将事物设为全局变量)。
【问题讨论】:
标签: python bdd pytest-bdd