My current situation is the following: I have a class C to be tested. To do so, I have a class TestC that (besides the tests) has a fixture f that creates an instance of C. Now, I have one test that checks how Cs interact. I'd like to invoke the fixture f twice, at best with different parameters. I thought that I can do that with lazy_fixture, but I'm not sure if I can pass parameters that way. What I'd like to achieve is
import pytest
class Test_Test:
@pytest.fixture(params=[0])
def f(self, request):
print(request.param)
return request.param
@pytest.mark.parametrize(
['arg1', 'arg2'],
[
pytest.lazy_fixture('f', params=[1]),
pytest.lazy_fixture('f', params=[2])
]
)
def test_1(arg1, arg2):
assert arg1 == 1
assert arg2 == 2
which of course does not work, but hopefully makes my intention clear.
Is something like this possible?