pytest--接口自动化测试
2022-04-28 本文已影响0人
sandy测试路
处理用例关联和依赖
参数化@pytest.mark.parametrize()
- 下图:用户名+密码登录异常场景,参数化用户名和密码
@pytest.mark.parametrize("identity, password", [("11", "11"), ("22", "22")])
def test_login_fail(identity, password):
data = {
"identity": identity,
"password": password,
"pid": "65edCTyg"
}
res = requests.post(url+"/tiger/v3/web/accounts/login", json=data)
assert res.status_code == 403
assert res.json()["error_code"] == "AC3_2"
assert res.json()["error_message"] == "用户不存在或者密码错误"