参数化:

l1 = [10086, 10010, 110, 120]
code = ["xxx","ppppp","oooo","wwww"]

@pytest.mark.parametrize("mobile,code",zip(l1,code))
def test_case(mobile,code):
print(mobile,code)
assert 1


结果:

=========================================================== test session starts ============================================================
platform win32 -- Python 3.6.6, pytest-5.3.2, py-1.8.1, pluggy-0.13.1 -- c:\python36\python.exe
cachedir: .pytest_cache
rootdir: D:\s27\day68, inifile: pytest.ini, testpaths: ./scripts
collected 4 items

scripts/test_case.py::test_case[10086-xxx] 10086 xxx
PASSED
scripts/test_case.py::test_case[10010-ppppp] 10010 ppppp
PASSED
scripts/test_case.py::test_case[110-oooo] 110 oooo
PASSED
scripts/test_case.py::test_case[120-wwww] 120 wwww
PASSED

============================================================ 4 passed in 0.07s =============================================================

猜你喜欢

转载自www.cnblogs.com/zhang-da/p/12219741.html