Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fixture to skip test if jax is not present #1066

Merged
merged 3 commits into from
Feb 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ def skip_if_no_tf_support(tf_support):
pytest.skip("Skipped, no tf support")


@pytest.fixture
def skip_if_no_jax_support():
pytest.importorskip("jax")


Comment on lines +143 to +147
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that this is simpler, but should we instead match the import pattern used for Torch and TF?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The above were written when I did not know of the existence of importorskip. I think this is simpler, and happy for the above to be rewritten to match.

@pytest.fixture(scope="module",
params=[1, 2, 3])
def seed(request):
Expand Down
4 changes: 3 additions & 1 deletion tests/qnn/test_cost.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ def skip_if_no_torch_support():


@pytest.mark.parametrize("interface", ALLOWED_INTERFACES)
@pytest.mark.usefixtures("skip_if_no_torch_support", "skip_if_no_tf_support")
@pytest.mark.usefixtures(
"skip_if_no_torch_support", "skip_if_no_tf_support", "skip_if_no_jax_support"
)
class TestSquaredErrorLoss:
def test_no_target(self, interface):
with pytest.raises(ValueError, match="The target cannot be None"):
Expand Down