Skip to content

Commit

Permalink
refactor: Move tests outside src
Browse files Browse the repository at this point in the history
  • Loading branch information
andrea-pasquale committed Feb 7, 2025
1 parent 9c4d8cb commit e21e431
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,6 @@ output-format = "colorized"
omit = ["src/qibojit/backends/clifford_operations*"]

[tool.pytest.ini_options]
testpaths = ['src/qibojit/tests/']
testpaths = ['tests/']
addopts = ['--cov=qibojit', '--cov-report=xml', '--cov-report=html']
env = ["D:NUMBA_DISABLE_JIT=1"]
2 changes: 1 addition & 1 deletion selfhosted
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

TMP_DIR=$(mktemp -d selfhosted.qibojit.XXXXXXX)

cp -r src/qibojit/tests "$TMP_DIR"
cp -r tests "$TMP_DIR"
cp pyproject.toml "$TMP_DIR/"
cd "$TMP_DIR/tests"

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/qibojit/tests/conftest.py → tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def pytest_addoption(parser):

@pytest.fixture
def backend(backend_name, request):
if request.config.getoption("--gpu-only"): # pragma: no cover
if request.config.getoption("--gpu-only"):
if backend_name not in ("cupy", "cuquantum"):
pytest.skip("Skipping non-gpu backend.")
yield BACKENDS.get(backend_name)()
Expand Down
7 changes: 3 additions & 4 deletions src/qibojit/tests/test_backends.py → tests/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
def test_device_setter(backend):
if backend.platform == "numba":
device = "/CPU:0"
else: # pragma: no cover
# CI does not have GPUs
else:
device = "/GPU:0"
backend.set_device(device)
assert backend.device == device
Expand Down Expand Up @@ -42,7 +41,7 @@ def test_sparse_cast(backend, array_type, format):
final = backend.to_numpy(backend.cast(sptarget))
target = sptarget.toarray()
backend.assert_allclose(final, target)
if backend.platform != "numba": # pragma: no cover
if backend.platform != "numba":
sptarget = getattr(backend.sparse, sptarget.__class__.__name__)(sptarget)
assert backend.is_sparse(sptarget)
final = backend.to_numpy(backend.cast(sptarget))
Expand All @@ -54,7 +53,7 @@ def test_to_numpy(backend):
target = backend.to_numpy(backend.cast(x))
if backend.platform == "numba":
final = backend.to_numpy(x)
else: # pragma: no cover
else:
final = backend.to_numpy(np.array(x))
backend.assert_allclose(final, target)

Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions src/qibojit/tests/test_ops.py → tests/test_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def generate_transpose_qubits(nqubits):
@pytest.mark.parametrize("nqubits,qubits", CONFIG)
@pytest.mark.parametrize("ndevices", [2, 4, 8])
def test_transpose_state(backend, nqubits, qubits, ndevices, dtype):
if backend.platform != "numba": # pragma: no cover
if backend.platform != "numba":
pytest.skip(
f"``transpose_state`` op is not available for {backend.platform} platform."
)
Expand All @@ -133,7 +133,7 @@ def test_transpose_state(backend, nqubits, qubits, ndevices, dtype):

@pytest.mark.parametrize("nqubits,local", CONFIG)
def test_swap_pieces_zero_global(backend, nqubits, local, dtype):
if backend.platform != "numba": # pragma: no cover
if backend.platform != "numba":
pytest.skip(
f"``swap_pieces`` op is not available for {backend.platform} platform."
)
Expand Down Expand Up @@ -165,7 +165,7 @@ def test_swap_pieces_zero_global(backend, nqubits, local, dtype):

@pytest.mark.parametrize("nqubits,qlocal,qglobal", CONFIG)
def test_swap_pieces(backend, nqubits, qlocal, qglobal, dtype):
if backend.platform != "numba": # pragma: no cover
if backend.platform != "numba":
pytest.skip(
f"``swap_pieces`` op is not available for {backend.platform} platform."
)
Expand Down
File renamed without changes.

0 comments on commit e21e431

Please sign in to comment.