1
@given("employees informations are added", target_fixture="information_db")
def ensure_employees_informations_added(): 
    return [_get_employee_information()]

我的问题是返回的列表会保存在 "information_db" 中吗?(我是使用 pytest 的新手)

4

1 回答 1

0

看起来您正在使用pytest-bdd除了裸 pytest 之外的插件。

该插件的文档可以在https://github.com/pytest-dev/pytest-bdd找到

长话短说,是的。返回的列表将保存在information_db名称下。

下一个子句可以通过将目标夹具的名称放入函数参数列表中来访问它:

@given("check employee")
def check_employee(information_db): 
    assert information_db[0]['skill'] == 42
于 2020-11-13T07:31:03.527 回答