diff --git a/tests/integration/backend_test.py b/tests/integration/backend_test.py index 43903229..637af29b 100644 --- a/tests/integration/backend_test.py +++ b/tests/integration/backend_test.py @@ -597,17 +597,11 @@ def test_simulator( assert len(stab_counts) == 2 # test non-clifford circuit fails on stabilizer backend - # unfortunately the job is accepted, then fails, so have to check get_result non_stab_circ = ( Circuit(2, name="non_stab_circ").H(0).Rx(0.1, 0).CX(0, 1).measure_all() ) - non_stab_circ = stabilizer_backend.get_compiled_circuit(non_stab_circ) - broken_handle = stabilizer_backend.process_circuit( - non_stab_circ, n_shots, language=language - ) - - with pytest.raises(GetResultFailed) as _: - _ = stabilizer_backend.get_result(broken_handle) + with pytest.raises(CircuitNotValidError): + _ = stabilizer_backend.get_compiled_circuit(non_stab_circ) @pytest.mark.skipif(skip_remote_tests, reason=REASON) diff --git a/tests/unit/backend.py b/tests/unit/backend.py new file mode 100644 index 00000000..21d9690f --- /dev/null +++ b/tests/unit/backend.py @@ -0,0 +1,26 @@ +import pytest +from pytket.predicates import CliffordCircuitPredicate + +from pytket.extensions.quantinuum import QuantinuumAPIOffline, QuantinuumBackend + + +@pytest.mark.parametrize( + "simulator_type,should_have_clifford_predicate", + [ + ("state-vector", False), + ("stabilizer", True), + ], +) +def test_clifford_circuits_for_stabilizer( + simulator_type: str, + should_have_clifford_predicate: bool, +) -> None: + qapi_offline = QuantinuumAPIOffline() + backend = QuantinuumBackend( + api_handler=qapi_offline, + simulator=simulator_type, + ) + required_predicates = backend.required_predicates + assert should_have_clifford_predicate == any( + (isinstance(pred, CliffordCircuitPredicate) for pred in required_predicates) + )