Skip to content

Commit d0aaa4a

Browse files
committed
catch PLDW
1 parent 23f294d commit d0aaa4a

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

tests/test_device.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import requests
1919

2020
import pennylane as qml
21+
from pennylane.exceptions import PennyLaneDeprecationWarning
2122
import numpy as np
2223

2324
import pennylane_aqt.device
@@ -425,7 +426,8 @@ class TestAQTDeviceIntegration:
425426
def test_load_from_device_function(self, num_wires, shots):
426427
"""Tests that the AQTDevice can be loaded from PennyLane `device` function."""
427428

428-
dev = qml.device("aqt.sim", wires=num_wires, shots=shots, api_key=SOME_API_KEY)
429+
with pytest.warns(PennyLaneDeprecationWarning, match="shots on device is deprecated"):
430+
dev = qml.device("aqt.sim", wires=num_wires, shots=shots, api_key=SOME_API_KEY)
429431

430432
assert dev.num_wires == num_wires
431433
assert dev.shots.total_shots == shots
@@ -464,7 +466,8 @@ def test_device_gets_local_config(self, monkeypatch, tmpdir):
464466
"pennylane.default_config", qml.Configuration("config.toml")
465467
) # force loading of config
466468

467-
dev = qml.device("aqt.sim", wires=2)
469+
with pytest.warns(PennyLaneDeprecationWarning, match="shots on device is deprecated"):
470+
dev = qml.device("aqt.sim", wires=2)
468471

469472
assert dev.shots.total_shots == 99
470473
assert API_HEADER_KEY in dev.header.keys()
@@ -487,7 +490,8 @@ def test_device_gets_api_key_default_config_directory(self, monkeypatch, tmpdir)
487490
c = qml.Configuration("config.toml")
488491
monkeypatch.setattr("pennylane.default_config", c) # force loading of config
489492

490-
dev = qml.device("aqt.sim", wires=2)
493+
with pytest.warns(PennyLaneDeprecationWarning, match="shots on device is deprecated"):
494+
dev = qml.device("aqt.sim", wires=2)
491495

492496
assert API_HEADER_KEY in dev.header.keys()
493497
assert dev.header[API_HEADER_KEY] == SOME_API_KEY
@@ -506,7 +510,8 @@ def test_device_gets_api_key_pennylane_conf_env_var(self, monkeypatch, tmpdir):
506510
"pennylane.default_config", qml.Configuration("config.toml")
507511
) # force loading of config
508512

509-
dev = qml.device("aqt.sim", wires=2)
513+
with pytest.warns(PennyLaneDeprecationWarning, match="shots on device is deprecated"):
514+
dev = qml.device("aqt.sim", wires=2)
510515

511516
assert API_HEADER_KEY in dev.header.keys()
512517
assert dev.header[API_HEADER_KEY] == SOME_API_KEY
@@ -519,7 +524,8 @@ def test_device_gets_api_key_aqt_token_env_var(self, monkeypatch):
519524
monkeypatch.setenv("PENNYLANE_CONF", "")
520525
monkeypatch.setenv("AQT_TOKEN", SOME_API_KEY + "XYZ987")
521526

522-
dev = qml.device("aqt.sim", wires=2)
527+
with pytest.warns(PennyLaneDeprecationWarning, match="shots on device is deprecated"):
528+
dev = qml.device("aqt.sim", wires=2)
523529

524530
assert API_HEADER_KEY in dev.header.keys()
525531
assert dev.header[API_HEADER_KEY] == NEW_API_KEY
@@ -528,8 +534,10 @@ def test_executes_with_online_api(self, monkeypatch):
528534
"""Tests that a PennyLane QNode successfully executes with a
529535
mocked out online API."""
530536

531-
dev = qml.device("aqt.sim", wires=2, shots=10, api_key=SOME_API_KEY)
537+
with pytest.warns(PennyLaneDeprecationWarning, match="shots on device is deprecated"):
538+
dev = qml.device("aqt.sim", wires=2, api_key=SOME_API_KEY)
532539

540+
@qml.set_shots(10)
533541
@qml.qnode(dev)
534542
def circuit(x, y):
535543
qml.RX(x, wires=0)

0 commit comments

Comments
 (0)