Skip to content

Commit

Permalink
fix: delaying backend construction in conftest
Browse files Browse the repository at this point in the history
  • Loading branch information
BrunoLiegiBastonLiegi committed Jun 18, 2024
1 parent 044148a commit 5f99465
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
10 changes: 5 additions & 5 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@


NAME2BACKEND = {
"tensorflow": TensorflowBackend(),
"pytorch": PyTorchBackend(),
"jax": JaxBackend(),
"tensorflow": TensorflowBackend,
"pytorch": PyTorchBackend,
"jax": JaxBackend,
}


@pytest.fixture
def backend(backend_name):
yield NAME2BACKEND[backend_name]
yield NAME2BACKEND[backend_name]()


AVAILABLE_BACKENDS = []
for backend_name in BACKENDS:
try:
_backend = NAME2BACKEND[backend_name]
_backend = NAME2BACKEND[backend_name]()
AVAILABLE_BACKENDS.append(backend_name)
except (ModuleNotFoundError, ImportError):
pass
Expand Down
5 changes: 4 additions & 1 deletion tests/test_backends.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import platform

import pytest

from qiboml.backends import MetaBackend
Expand All @@ -13,5 +15,6 @@ def test_metabackend_load_error():


def test_metabackend_list_available():
available_backends = {"tensorflow": True, "pytorch": True, "jax": True}
tensorflow = False if platform.system() == "Windows" else True
available_backends = {"tensorflow": tensorflow, "pytorch": True, "jax": True}
assert MetaBackend().list_available() == available_backends

0 comments on commit 5f99465

Please sign in to comment.