Skip to content

Commit d2f3a95

Browse files
[testing] [Python] Fix issue#2641 (#2732)
Make the `braket` and `quera` Python tests conditional Signed-off-by: Pradnya Khalate <[email protected]>
1 parent a79d9ab commit d2f3a95

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

python/tests/kernel/test_explicit_measurements.py

+16-4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
import os
1212
import numpy as np
1313

14+
skipIfBraketNotInstalled = pytest.mark.skipif(
15+
not (cudaq.has_target("braket")),
16+
reason='Could not find `braket` in installation')
17+
1418

1519
@pytest.fixture(autouse=True)
1620
def do_something():
@@ -230,10 +234,8 @@ def can_set_target(name):
230234

231235

232236
@pytest.mark.parametrize("target, env_var",
233-
[("anyon", ""), ("braket", ""),
234-
("infleqtion", "SUPERSTAQ_API_KEY"),
235-
("ionq", "IONQ_API_KEY"), ("quantinuum", ""),
236-
("quera", "")])
237+
[("anyon", ""), ("infleqtion", "SUPERSTAQ_API_KEY"),
238+
("ionq", "IONQ_API_KEY"), ("quantinuum", "")])
237239
def test_unsupported_targets(target, env_var):
238240
if env_var:
239241
os.environ[env_var] = "foobar"
@@ -247,6 +249,16 @@ def test_unsupported_targets(target, env_var):
247249
cudaq.reset_target()
248250

249251

252+
@skipIfBraketNotInstalled
253+
@pytest.mark.parametrize("target", ["braket", "quera"])
254+
def test_unsupported_targets2(target):
255+
cudaq.set_target(target)
256+
with pytest.raises(RuntimeError) as e:
257+
test_simple_kernel()
258+
assert "not supported on this target" in repr(e)
259+
cudaq.reset_target()
260+
261+
250262
def test_error_cases():
251263
""" Test for throw error if user attempts to use a measurement result in
252264
conditional logic. """

0 commit comments

Comments
 (0)