Problem
The PHP side is well covered (Pest, ~90% line coverage), but the Python scripts in bin/python/ have no automated tests and no test harness. This is now a concrete gap because circuit.py contains non-trivial pure logic:
_validate_gates() — qubit-index range validation, measure targets handling, the isinstance(index, bool) guard, and the _QUBIT_INDEX_KEYS allowlist that must stay in sync with _build_circuit().
These are exactly the kind of guards that get silently broken by a future refactor with nothing to catch the regression. Today they are only verified by ad-hoc manual invocation.
Proposal
- Add a minimal pytest harness under
bin/python/ (e.g. tests/ + requirements-dev.txt with pytest).
_validate_gates() and _build_circuit's gate-dispatch are importable without the Braket SDK (braket is imported lazily inside the functions), so the validation logic can be unit-tested with no AWS/Braket dependency.
- Cover: valid circuits pass; out-of-range / negative / non-int indices raise
ValueError; scalar measure.targets; measure-all (null); unknown gate type.
- Wire
pytest into the CI workflow (.github/workflows/tests.yml) as a separate step.
Acceptance
pytest runs in CI and covers _validate_gates (and ideally _build_circuit with a mocked/stubbed Braket Circuit).
- The bool-is-int guard and the
_QUBIT_INDEX_KEYS/_build_circuit coupling have explicit regression tests.
Problem
The PHP side is well covered (Pest, ~90% line coverage), but the Python scripts in
bin/python/have no automated tests and no test harness. This is now a concrete gap becausecircuit.pycontains non-trivial pure logic:_validate_gates()— qubit-index range validation,measuretargets handling, theisinstance(index, bool)guard, and the_QUBIT_INDEX_KEYSallowlist that must stay in sync with_build_circuit().These are exactly the kind of guards that get silently broken by a future refactor with nothing to catch the regression. Today they are only verified by ad-hoc manual invocation.
Proposal
bin/python/(e.g.tests/+requirements-dev.txtwithpytest)._validate_gates()and_build_circuit's gate-dispatch are importable without the Braket SDK (braket is imported lazily inside the functions), so the validation logic can be unit-tested with no AWS/Braket dependency.ValueError; scalarmeasure.targets; measure-all (null); unknown gate type.pytestinto the CI workflow (.github/workflows/tests.yml) as a separate step.Acceptance
pytestruns in CI and covers_validate_gates(and ideally_build_circuitwith a mocked/stubbed Braket Circuit)._QUBIT_INDEX_KEYS/_build_circuitcoupling have explicit regression tests.