I have a fixture that returns a list, and I want to create a test for each element in that list, so I was trying to pass it as an argument in pytest.parametrize, but it returns the whole list and just creates a single test.
@pytest.fixture()
def letters():
lettersABC = ['A', 'B', 'C', 'D']
return lettersABC
@pytest.mark.asyncio
@pytest.mark.parametrize('letter', ["letters"])
async def test_per_letter(letter, request):
name = request.getfixturevalue(letter)
print(f'name {name}')
assert name == 'A'
The result of this is:
FAILED digital_alarms_auto_test.py::test_per_letter[letters] - AssertionError: assert ['A', 'B', 'C', 'D'] == 'A'
===================================================================================================== 1 failed,
This is just an example of what I want to do as the real code is more complex. Letters has to be a fixture, not just a function