I have next code for pytest:
import pytest
@pytest.fixture
def my_fixture():
def _method(a_list):
return [num*0.5 for num in a_list]
return _method
# @pytest.mark.parametrize ??
def test_me(my_fixture):
pre_list = [0, 3, 1, 2]
finally_list = my_fixture(pre_list)
for i in finally_list:
assert i < 10
The meaning is as follows. I have the initial data for the test ("pre_list"). First I need to convert them using a fixture. I did it through an additional function in the fixture, "_method(a_list)". But then the values obtained from 'finally_list' I want to use for parameterization within the current test. Is it really possible to do this? To convert the data from the test using a fixture, and then use them to parametrize the same test
While I run all the values through for:
for i in finally_list: assert i < 10
But this is not what I would like. I would like to have a separate test for each value through parameterization.