pytest设置单个函数和多个函数的参数化

def init_data():
    data = [{"zhang", "123"}, {"lisang", "456"}]
    return data

class test_skip:

    #单个参数
    @pytest.mark.parametrize('name', ["tom", "zhang", "jun"])
    def test_a(self,name):
        print(name)

    #多个参数
    @pytest.mark.parametrize("username,password", init_data())
    def  test_b(self,username,password):
        print("用户名:%s,密码:%s 成功!"%(username,password))

  

原文地址:https://www.cnblogs.com/chongyou/p/12634864.html