【问题标题】:What are target fixtures used for?目标夹具是做什么用的?
【发布时间】:2020-11-12 09:51:12
【问题描述】:
@given("employees informations are added", target_fixture="information_db")
def ensure_employees_informations_added(): 
    return [_get_employee_information()]

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

【问题讨论】:

    标签: python pytest bdd fixtures pytest-bdd


    【解决方案1】:

    看起来你在使用 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
    

    【讨论】:

      猜你喜欢
      • 2010-09-05
      • 2021-08-30
      • 2010-10-06
      • 1970-01-01
      • 2020-10-10
      • 2014-12-27
      • 2018-07-02
      • 1970-01-01
      • 2020-04-14
      相关资源
      最近更新 更多