Skip to content

Commit

Permalink
Adds error msg test when a task fail
Browse files Browse the repository at this point in the history
  • Loading branch information
y4izus committed Jul 15, 2024
1 parent d3e383c commit f158943
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/test_transpiler_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,28 @@ def test_transpile_malformed_body():
)


def test_transpile_failing_task():
open_qasm_circuit = 'OPENQASM 2.0;\ninclude "qelib1.inc";\ngate dcx q0,q1 { cx q0,q1; cx q1,q0; }\nqreg q[3];\ncz q[0],q[2];\nsdg q[1];\ndcx q[2],q[1];\nu3(3.890139082217223,3.447697582994976,1.1583481971959322) q[0];\ncrx(2.3585459177723522) q[1],q[0];\ny q[2];'
circuit = QuantumCircuit.from_qasm_str(open_qasm_circuit)
transpiler_service = TranspilerService(
backend_name="ibm_kyoto",
ai="false",
optimization_level=3,
coupling_map=[[1, 2], [2, 1]],
qiskit_transpile_options={
"basis_gates": ["u1", "u2", "u3", "cx"],
"seed_transpiler": 0,
},
)

try:
transpiler_service.run(circuit)
pytest.fail("Error expected")
except Exception as e:
assert "The background task" in str(e)
assert "FAILED" in str(e)


def compare_layouts(plugin_circ, non_ai_circ):
assert (
plugin_circ.layout.initial_layout == non_ai_circ.layout.initial_layout
Expand Down

0 comments on commit f158943

Please sign in to comment.