如何通过Pytest结合yaml实现参数化接口测试实战?
- 内容介绍
- 文章标签
- 相关推荐
本文共计109个文字,预计阅读时间需要1分钟。
直接输出简化后的代码:
python@pytest.mark.parametrize(mobile, appkey, get_data([mobile_belong_get]))def test_mobile(mobile, appkey): r=requests.get('https://api.binstd.com/shouji/query', params={shouj: mobile})
一、废话不罗嗦,直接上代码
@pytest.mark.parametrize("mobile, appkey", get_data["mobile_belong_get"])def test_mobile(mobile, appkey):
r = requests.get('api.binstd.com/shouji/query', params={
"shouji": mobile,
"appkey": appkey
})
print(r.status_code)
assert r.status_code == 200
print(r.json())
print("zhou")
二、yaml数据
本文共计109个文字,预计阅读时间需要1分钟。
直接输出简化后的代码:
python@pytest.mark.parametrize(mobile, appkey, get_data([mobile_belong_get]))def test_mobile(mobile, appkey): r=requests.get('https://api.binstd.com/shouji/query', params={shouj: mobile})
一、废话不罗嗦,直接上代码
@pytest.mark.parametrize("mobile, appkey", get_data["mobile_belong_get"])def test_mobile(mobile, appkey):
r = requests.get('api.binstd.com/shouji/query', params={
"shouji": mobile,
"appkey": appkey
})
print(r.status_code)
assert r.status_code == 200
print(r.json())
print("zhou")
二、yaml数据

