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

[testing] [Python] Fix issue#2641 #2732

Merged
merged 4 commits into from
Mar 16, 2025
Merged
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
20 changes: 16 additions & 4 deletions python/tests/kernel/test_explicit_measurements.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
import os
import numpy as np

skipIfBraketNotInstalled = pytest.mark.skipif(
not (cudaq.has_target("braket")),
reason='Could not find `braket` in installation')


@pytest.fixture(autouse=True)
def do_something():
Expand Down Expand Up @@ -230,10 +234,8 @@ def can_set_target(name):


@pytest.mark.parametrize("target, env_var",
[("anyon", ""), ("braket", ""),
("infleqtion", "SUPERSTAQ_API_KEY"),
("ionq", "IONQ_API_KEY"), ("quantinuum", ""),
("quera", "")])
[("anyon", ""), ("infleqtion", "SUPERSTAQ_API_KEY"),
("ionq", "IONQ_API_KEY"), ("quantinuum", "")])
def test_unsupported_targets(target, env_var):
if env_var:
os.environ[env_var] = "foobar"
Expand All @@ -247,6 +249,16 @@ def test_unsupported_targets(target, env_var):
cudaq.reset_target()


@skipIfBraketNotInstalled
@pytest.mark.parametrize("target", ["braket", "quera"])
def test_unsupported_targets2(target):
cudaq.set_target(target)
with pytest.raises(RuntimeError) as e:
test_simple_kernel()
assert "not supported on this target" in repr(e)
cudaq.reset_target()


def test_error_cases():
""" Test for throw error if user attempts to use a measurement result in
conditional logic. """
Expand Down
Loading