parametrize:
(1)支持元组,列表
(2)支持列表嵌套列表,列表嵌套元组,列表嵌套字典
1、单个变量参数为 列表
datatest04=['zhangsan','lisi']
@pytest.mark.parametrize('user', datatest04)
def test_04(self,user):
print(user)
2、单个变量参数为 元组
datatest08=("zhangsan","lisi")
@pytest.mark.parametrize("data", datatest08)
def test_08(self,data):
print(data)
3、多个变量组成列表嵌套元组
data =[("zhangsan","111111111"),("lisi","2222222")]
@pytest.mark.parametrize('user,password',data)
def test_03(self,user,password):
print(user,password)
4、多个变量组成列表嵌套列表
data = [["zhangsan", "111111111"], ["lisi", "2222222"]]
@pytest.mark.parametrize('user,password', data)
def test_05( user, password):
print(user, password)
5、列表嵌套字典
datatest07 = [{"user": "zhangsan", "password": "111111111"}, {"user": "lisi", "password": "222222"}]
@pytest.mark.parametrize("data", datatest07)
def test_07(self, data):
print(data)
print(data["user"], data["password"])
6、组合函数-笛卡尔集
data1 = ["zhangsan", "lisi"]
data2 = ["1111111", "2222222"]
@pytest.mark.parametrize('user', data1)
@pytest.mark.parametrize('password', data2)
def test_06( user, password):
print(user, password)
|