I have a code where in the fixture there will be authorization, sending a request, receiving a response, getting a list from the response. The result will be just a list with the values that I need to pass from the fixture for parameterization in many tests. Please tell me, is it possible? For example, I specified a predefined list, but the values in it will be changed, it will depend on the response to the request:
import pytest
import requests
@pytest.fixture()
def conf_response():
request_list = [1, 2, 2]
return request_list
@pytest.mark.parametrize(
"a",
[
(pytest.lazy_fixture("conf_response")),
],
)
def test_one(a):
assert a > 0
@pytest.mark.parametrize(
"a",
[
(pytest.lazy_fixture("conf_response")),
],
)
def test_two(a):
assert a == 0
I tried use
pytest.lazy_fixture
But it does not take values from the list for tests, it takes the whole . Also tried pytest-cases but he also does not to work with list.
I would recommend parametrizing the fixture instead of the test cases.
Consider the following example --