tests: fix backend assignation for tests

This commit is contained in:
Éloi Rivard 2023-11-24 10:10:36 +01:00
parent 8a5dd04c87
commit 79533acc4b
No known key found for this signature in database
GPG key ID: 7EDA204EA57DD184

View file

@ -40,10 +40,8 @@ def pytest_generate_tests(metafunc):
backends &= set(metafunc.config.getoption("backend"))
# tests in tests.backends.BACKENDNAME should only run one backend
if metafunc.module.__name__.startswith("tests.backends"):
module_name_parts = metafunc.module.__name__.split(".")
in_backend_module = len(module_name_parts) > 3
if in_backend_module:
if module_name_parts[0:2] == ["tests", "backends"] and len(module_name_parts) > 3:
backend = module_name_parts[2]
if backend not in backends: # pragma: no cover
pytest.skip()
@ -51,7 +49,7 @@ def pytest_generate_tests(metafunc):
metafunc.parametrize("backend", [lazy_fixture(f"{backend}_backend")])
return
if "backend" in metafunc.fixturenames:
elif "backend" in metafunc.fixturenames:
metafunc.parametrize(
"backend", [lazy_fixture(f"{backend}_backend") for backend in backends]
)