列表传参
list1 = [1, 2, 3]
@pytest.mark.parametrize('data', list1)
def test_ddt1(data):
print(data)
元组传参
tup1 = (1, 2, 3)
@pytest.mark.parametrize('data', tup1)
def test_ddt1(data):
print(data)
列表嵌套
datas1 = [('tom', '123456', '登陆成功'), ('jack', '123456', '登陆失败'), ('rose', '123456', '登陆失败')]
datas2 = [{'name': 'tom', 'password': '123456', 'expected': '登陆成功'},
{'name': 'jack', 'password': '123456', 'expected': '登陆失败'},
{'name': 'rose', 'password': '123456', 'expected': '登陆失败'}]
@pytest.mark.parametrize('name,password,expected', datas1)
def test_ddt1(name, password, expected):
print(name)
print(password)
print(expected)
@pytest.mark.parametrize('casedata', datas2)
def test_ddt1(casedata):
print(casedata)
print(casedata['name'])
print(casedata['password'])
print(casedata['expected'])
@pytest.mark.parametrize参数化详细说明推荐pytest系列——实现用例参数化(@pytest.mark.parametrize)_pytest.mark.parametrize 参数-CSDN博客
标签:parametrize,pytest,mark,expected,测试用例,print,password From: https://blog.csdn.net/sinat_37472649/article/details/143502991