import pytest
test_datas = [
(11, 22, 33),
(22, 33, 55)
]
datas_dict = [
{"a": 1, "b": 2, "c": 3},
{"a": 11, "b": 22, "c": 33},
{"a": 111, "b": 222, "c": 333},
]
@pytest.mark.parametrize("a, b, c", [(1, 2, 3), (4, 5, 9)])
def test_add01(a, b, c):
res = a + b
assert res == c
@pytest.mark.parametrize("data", test_datas)
def test_add02(data):
res = data[0] + data[1]
assert res == data[2]
@pytest.mark.parametrize("data", datas_dict)
def test_add03(data):
res = data["a"] + data["b"]
assert res == data["c"]
常用举例:
```python
@pytest.mark.parametrize(test_input,expected,[
({"a": 1, "b": 2, "c": 3},200),
({"a": 11, "b": 22, "c": 33},200),
({"a": 111, "b": 222, "c": 333},200)
])
def test_YiDongDuanYanZhengMaDengLu_001(self,test_input,expected):
"""移动端验证码登录"""
r = self.obj.post_app(row=2, data=test_input)
print("移动端验证码登录 is:", r.text)
self.log.info("获取请求结果:%s" % r.text)
assert r.status_code == expected
assert str(r.json()["msg"]) == "成功"