Skip to content

Commit

Permalink
feat: added option to run only gpu tests in conftest
Browse files Browse the repository at this point in the history
  • Loading branch information
BrunoLiegiBastonLiegi committed Feb 5, 2025
1 parent cb89902 commit f48eff6
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/qibojit/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

from qibojit.backends import CupyBackend, CuQuantumBackend, NumbaBackend


def pytest_addoption(parser):
parser.addoption(
"--gpu_only",
action="store_true",
default=False,
help="Run on GPU backends only.",
)


BACKENDS = {"numba": NumbaBackend, "cupy": CupyBackend, "cuquantum": CuQuantumBackend}

# ignore backends that are not available in the current testing environment
Expand All @@ -15,7 +25,10 @@


@pytest.fixture
def backend(backend_name):
def backend(backend_name, request):
if request.config.getoption("--gpu_only"):
if backend_name not in ("cupy", "cuquantum"):
pytest.skip("Skipping non-gpu backend.")

Check warning on line 31 in src/qibojit/tests/conftest.py

View check run for this annotation

Codecov / codecov/patch

src/qibojit/tests/conftest.py#L30-L31

Added lines #L30 - L31 were not covered by tests
yield BACKENDS.get(backend_name)()


Expand Down

0 comments on commit f48eff6

Please sign in to comment.