Fixtures are a great way to make your tests modular, no question there. parametrizeed tests save a lot of time and typing. However, for some reason it is hard to combine both of those techniques together. If you simply pass fixtures to mark.parametrize
it will not work at all. There is a trick, it is not pretty but works ok. You need to pass fixture names as strings and then fetch them in your test using getfixturevalue
that comes with a request
fixture. Sounds weird and confusing? Well, it is. It is a hack.
@pytest.mark.parametrize("input_fixture", [("fixtureA", ), ("fixtureB",)])
def test_thatTakesFixturesAsParameters(self, input_fixture, request):
value = request.getfixturevalue(input_fixture)