I am working on a django reusable package that I plan to use with multiple projects. I used pytest to build a test suite, I used a parameterization that helped pytest run a single test with several settings.
However, I would like to run all my tests using various combinations of settings
available_backends = [
'django_profile.auth_backends.drf.RestFramework',
'django_profile.auth_backends.kong.Kong',
]
def pytest_generate_tests(metafunc):
if 'auth_backend' in metafunc.fixturenames:
metafunc.parametrize(
'auth_backend',
available_backends
)
@pytest.fixture(params=['auth_backend', ])
def auth_backend(request, settings):
settings.DJANGO_PROFILE_AUTH_BACKEND = request.auth_backend
return settings
I experimented with the above approach, but it also means that I have to add auth_backend
to each test case, I do not think this is ideal. Can anyone recommend me to run all my tests using different combinations of settings?
Hi
source
share