qml.devices.tests.test_device

test_device(device_name, shots=0, skip_ops=True, flaky_report=False, pytest_args=None, **kwargs)[source]

Run the device integration tests using an installed PennyLane device.

Parameters
  • device_name (str) – the name of the device to test

  • shots (int or None) – The number of shots/samples used to estimate expectation values and probability. If shots=None, then the device is run in analytic mode (where expectation values and probabilities are computed exactly from the quantum state). If not provided, the device default is used.

  • skip_ops (bool) – whether to skip tests that use operations not supported by the device

  • pytest_args (list[str]) – additional PyTest arguments and flags

  • **kwargs – Additional device keyword args

Example

>>> from pennylane.devices.tests import test_device
>>> test_device("default.qubit.legacy")
================================ test session starts =======================================
platform linux -- Python 3.7.7, pytest-5.4.2, py-1.8.1, pluggy-0.13.1
rootdir: /home/josh/xanadu/pennylane/pennylane/devices/tests, inifile: pytest.ini
devices: flaky-3.6.1, cov-2.8.1, mock-3.1.0
collected 86 items
xanadu/pennylane/pennylane/devices/tests/test_gates.py ..............................
...............................                                                       [ 70%]
xanadu/pennylane/pennylane/devices/tests/test_measurements.py .......sss...sss..sss   [ 95%]
xanadu/pennylane/pennylane/devices/tests/test_properties.py ....                      [100%]
================================= 77 passed, 9 skipped in 0.78s ============================