pytest - got empty parameter set

2.1k views Asked by At

I am trying to automate an api, basically what I want to do is execute test_001_post_desafio, save information from its response in a list and use it in test_002_post_validate, but when executing the latter with pytest I get the error: "SKIPPED [1] test_email.py:43: got empty parameter set ['otp', 'idOtp', 'subdomain']"

What am I doing wrong?

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

I could do the whole test inside a testcase, but I think it is not very elegant

0

There are 0 answers