I have a lot of parametrized fixtures managed via pytest.
Sometimes, I want tests using the fixture not to have to worry about applying parameters.
Is it possible to make a fixture that parametrizes another fixture?
import pytest
class Foo:
def __init__(self, a: int, b: int):
pass
@pytest.fixture
def foo(a: int, b: int) -> Foo:
return Foo(a, b)
@pytest.fixture
@pytest.mark.parametrize("a, b", [(2, 3)]) # How can I do this?
def fixture_parametrizing_another_fixture(foo: Foo) -> Foo:
return foo
# I don't want to parametrize here, I want the fixture already set up
def test_with_second_fixture(fixture_parametrizing_another_fixture: Foo):
pass