Skip to content

Commit a518cdc

Browse files
committed
Revert "tests: remove some useless pytest --backend detection code"
This reverts commit b449da8.
1 parent 7b45b1f commit a518cdc

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

tests/conftest.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ def test_backends():
2424

2525
for backend in backends:
2626
backend_dir = os.path.join("tests", "backends", backend)
27+
if not os.path.isdir(backend_dir):
28+
expanded.add(backend)
29+
continue
30+
2731
variants = [
2832
f[:-3]
2933
for f in os.listdir(backend_dir)
@@ -73,6 +77,20 @@ def pytest_generate_tests(metafunc):
7377
from pytest_lazy_fixtures import lf
7478

7579
backends = test_backends()
80+
requested = metafunc.config.getoption("backend")
81+
82+
if requested:
83+
filtered = set()
84+
for req in requested:
85+
if ":" in req:
86+
if req in backends:
87+
filtered.add(req)
88+
else:
89+
for backend in backends:
90+
if backend == req or backend.startswith(f"{req}:"):
91+
filtered.add(backend)
92+
backends = filtered
93+
7694
backends = sorted(backends)
7795

7896
module_name_parts = metafunc.module.__name__.split(".")
@@ -82,7 +100,9 @@ def pytest_generate_tests(metafunc):
82100
b for b in backends if b == backend_path or b.startswith(f"{backend_path}:")
83101
]
84102

85-
if "backend" in metafunc.fixturenames:
103+
if not matching:
104+
pytest.skip()
105+
elif "backend" in metafunc.fixturenames:
86106
fixture_names = []
87107
for spec in matching:
88108
fixture_name = (

0 commit comments

Comments
 (0)