I'm trying to use a parametrized fixture multiple times in a single test, with the intent of getting a cartesian product of all of its values.
https://stackoverflow.com/a/39444098/102441 shows how to do this for a simple fixture:
import pytest
@pytest.fixture(params=[0, 1, 2])
def first(request):
return request.param
second = first
# runs 3x3 = 9 times
def test_double_fixture(first, second):
assert False, '{} {}'.format(first, second)
However, this approach falls apart if the parametrization comes from a dependent fixture:
import pytest
@pytest.fixture(params=[0, 1, 2])
def integer(request):
return request.param
@pytest.fixture
def squared_integer(integer):
return integer * integer
@pytest.fixture
def first(squared_integer):
return squared_integer
second = first
# runs only 3 times
def test_double_fixture(first, second):
assert False, '{} {}'.format(first, second)
How can I make this run 3x3 tests like the simple example does?