testCan.py
import pytest
tup=[("xiaqiang", "123456"), ("rose", "123456"), ("jone", "123456"), ("Alix", "123456")]#列表里嵌套元祖
@pytest.mark.parametrize("userName,passWord",tup)
def test_login(userName, passWord):
print(userName + " : " + passWord)
#assert userName == 'rose','这里userName不等于rose'
class TestPrame:
@pytest.mark.parametrize("name",['zhangshan','yanzhenma','李雨桐'])
def test_prame01(self,name):#def函数和@pytest.mark.parametrize之间不能隔开,空行/注释代码都不行,隔开就不打印内容
print(name)
#print(name)
if __name__ == '__main__':
pytest.main(["-vs"])
test_login(userName, passWord):打印如下:
testCan.py .xiaqiang : 123456
.rose : 123456
.jone : 123456
.Alix : 123456
test_prame01(self,name)打印如下:
testCan.py
.zhangshan
.yanzhenma
.李雨桐