@given("employees informations are added", target_fixture="information_db")
def ensure_employees_informations_added():
return [_get_employee_information()]
我的问题是返回的列表会保存在“information_db”中吗?(我是pytest的新手)
@given("employees informations are added", target_fixture="information_db")
def ensure_employees_informations_added():
return [_get_employee_information()]
看起来你正在使用除了裸的 pytest 外的 pytest-bdd 插件。
插件的文档可以在 https://github.com/pytest-dev/pytest-bdd 找到。
长话短说,是的。返回的列表将保存在 information_db
的名称下。
下一个从句可以通过将目标 fixture 的名称放入函数参数列表中来访问它:
@given("check employee")
def check_employee(information_db):
assert information_db[0]['skill'] == 42