如何在 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 从何时传递到那时?
(我曾尝试将 newN1 设为全局变量……这可行,但在 python 中通常不赞成将事物设为全局)。