I have a directory full of data files to feed into tests, and I load them using something along the lines of
@pytest.fixture(scope="function")
def test_image_one():
return load_image("test_image_one.png")
As the test suite grows, this is becoming unmaintainable. Is there a way to programatically create fixtures? Ideally it would be something like:
for fname in ["test_image_one", "test_image_two", ...]:
def pytest_fixutre_function():
return load_image("{}.png".format(fname))
pytest.magic_create_fixture_function(fname, pytest_fixutre_function)
Is there a way to accomplish this?