我正在尝试自动化一个api,基本上我想做的是执行test_001_post_desafio,将其响应中的信息保存在一个列表中,并在test_002_post_validate中使用它,但在使用pytest执行后者时,我得到错误: 已跳过[1]测试。\u电子邮件。py:43:获取空参数集['otp'、'idOtp'、'子域']
我做错了什么
subdominios = ["20", "21", "22", "23", "24", "25", "99", "22", "11"]
desafios = []
#This works fine!!!
@pytest.mark.parametrize("subdominio", [subdominio for subdominio in subdominios])
def test_001_post_desafio(subdominio, payload, header):
response_create = requests.post(
"some url" + subdominio,
data=json.dumps(payload),
headers=header,
verify=False)
response_json = response_create.json()
#Here i append the data i need for test_002_post_validate
desafios.append((response_json["otp"], response_json["idOtp"], subdominio))
assert response_create.status_code == 200
#here is where i get SKIPPED [1] test_email.py:43: got empty parameter set ['otp', 'idOtp', 'subdominio']
@pytest.mark.parametrize("otp, idOtp, subdominio", [otp for otp in desafios])
def test_002_post_validate(otp, idOtp, subdominio, header):
response = requests.post("some Url 1" + idOtp +
"some url2" + subdominio,
data=json.dumps({"otp": otp}),
headers=header,
verify=False)
assert response.status_code == 204
我可以在一个测试用例中完成整个测试,但我认为它不是很优雅
目前没有回答
相关问题 更多 >
编程相关推荐