From 6c2b1b4809bed40949a7e8e1dcb615ac8b09955d Mon Sep 17 00:00:00 2001 From: Guillaume Schurck Date: Thu, 7 Nov 2024 14:56:42 +0100 Subject: [PATCH] test: passing average_nb_photons option to backend.run() is not allowed --- tests/local/test_backend.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/local/test_backend.py b/tests/local/test_backend.py index 8c53470..d154938 100644 --- a/tests/local/test_backend.py +++ b/tests/local/test_backend.py @@ -1,6 +1,7 @@ from typing import List import numpy as np +import pytest from qiskit import QuantumCircuit, transpile from qiskit.circuit.library import Initialize @@ -43,6 +44,17 @@ def test_set_execution_backend_options() -> None: assert sum(backend.run(transpiled).result().get_counts().values()) == 7 +def test_run_override_nbar_error() -> None: + """ + Test that passing average_nb_photons option to backend.run() is not allowed + """ + circ = QuantumCircuit(1, 1) + backend = ProcessorSimulator(PhysicalCatProcessor()) + transpiled = transpile(circ, backend) + with pytest.raises(ValueError): + _ = backend.run(transpiled, shots=100, average_nb_photons=4) + + def test_translation_plugin() -> None: backend = ProcessorSimulator(SimpleProcessor(1))