Skip to content

Commit

Permalink
fix(tests): run all samples via no machine test
Browse files Browse the repository at this point in the history
  • Loading branch information
qartik committed Nov 3, 2023
1 parent be179e5 commit 47a2ba9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pytket/phir/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def pytket_to_phir(

if machine:
# Only print message if a machine object is passed
# Otherwise, placment and routing are functionally skipped
# Otherwise, placement and routing are functionally skipped
# The function is called, but the output is just filled with 0s
logger.debug("Performing placement and routing...")
placed = place_and_route(shards, machine)
Expand Down
15 changes: 12 additions & 3 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,20 @@


class TestApi:
def test_pytket_to_phir_no_machine(self) -> None:
@pytest.mark.parametrize("test_file", list(QasmFile))
def test_pytket_to_phir_no_machine(self, test_file: QasmFile) -> None:
"""Test case when no machine is present."""
circuit = get_qasm_as_circuit(QasmFile.baby)
circuit = get_qasm_as_circuit(test_file)

assert pytket_to_phir(circuit)
match test_file:
case QasmFile.big_gate:
with pytest.raises(KeyError, match=r".*CnX.*"):
assert pytket_to_phir(circuit)
case QasmFile.qv20_0:
with pytest.raises(KeyError, match=r".*U3.*"):
assert pytket_to_phir(circuit)
case _:
assert pytket_to_phir(circuit)

@pytest.mark.parametrize("test_file", list(QasmFile))
def test_pytket_to_phir_h1_1_all_circuits(self, test_file: QasmFile) -> None:
Expand Down

0 comments on commit 47a2ba9

Please sign in to comment.