zoukankan      html  css  js  c++  java
  • pytest:fixture中有入参时如何编写

    如果fixture中需要入参时,不是直接返回数据,而是返回生成数据的函数。然后可以在测试用例中调用此函数。

    @pytest.fixture
    def make_customer_record():
        def _make_customer_record(name):
            return {"name": name, "orders": []}
    
        return _make_customer_record
    
    
    def test_customer_records(make_customer_record):
        customer_1 = make_customer_record("Lisa")
        customer_2 = make_customer_record("Mike")
        customer_3 = make_customer_record("Meredith")
  • 相关阅读:
    深入理解多态..............................
    走过路过 不要错过..
    进军C#..
    员工打卡....
    MySQL
    MySQL
    MySQL
    MySQL
    MySQL
    MySQL
  • 原文地址:https://www.cnblogs.com/gcgc/p/12744369.html
Copyright © 2011-2022 走看看