What is the correct syntax to use my_list fixture with parametrize in pytest? I would like test_item() to be run 5 times (based on the list returned by my_list fixture)
@pytest.fixture
def my_list():
return [1, 2, 3, 4, 5]
@pytest.mark.parametrize("item", my_list())
def test_item(item):
print(item)
assert item < 6
I tried also this, but did not succeed:
import pytest
@pytest.fixture
def my_list():
return [1, 2, 3, 4, 5]
@pytest.mark.parametrize("item", "my_list")
def test_item(item, request):
item = request.getfixturevalue("item")
print(item)
assert item < 6
Thanks in advance