• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Qiskit / qiskit / 19511142843
88%

Build:
DEFAULT BRANCH: main
Ran 19 Nov 2025 06:30PM UTC
Jobs 1
Files 875
Run time 3min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

19 Nov 2025 05:23PM UTC coverage: 88.215% (+0.005%) from 88.21%
19511142843

push

github

web-flow
Add C API testing framework to Python tests (#14958)

* Add C API testing framework to Python tests

Right now the Qiskit C API (and by extension the internal rust code) is
lacking some of the helper utilities necessary to do deeper validation
of the output circuits. Mainly `Operator.from_circuit` to do unitary
equivalence checks accounting for a layout introduced by the transpiler.
But also things like just circuit equality checks are easier in Python
because the tooling doesn't exist in pure-Rust/C yet. As we're building
the C API to be the universal interface to Qiskit from any programming
language it is very easy to leverage the C API from Python.

This commit adds a new testing framework to the Python tests that builds
a C FFI using ctypes to call into the loaded compiled extension (which
already bundles the C API). It then wraps that ffi in a couple of helper
functions to go from a Python circuit to a C circuit, build a c target
from basis gates and a coupling map, and then a function to transpile a
c circuit using the C api which returns a Python circuit. This enables
us to write tests in Python and validate the output circuits are
equivalent accounting for layout and permutations the transpiler
applies. It also lets us use any other tooling we have in Python for
testing.

This framework does not eliminate the need for
testing the C API directly from C, it is only intended to do deeper
testing while the functionality exposed to C is more limited
specifically for the transpiler.

The tests added in this PR are just a starting point and basically are
copies of Python space full path various transpilation tests. This is
not expected to be the final set of tests, but more just serve as a
starting point.

* Add safety comment

* Add missing return types to ctypes interface

* Fix ctypes interface def order

* Add helper function for building c arrays

* Add free on cleanup to tests

* Update test/python/c_api/ffi.py

Co-authored-by: Julien Gacon <ga... (continued)

10 of 10 new or added lines in 1 file covered. (100.0%)

24 existing lines in 4 files now uncovered.

94333 of 106935 relevant lines covered (88.22%)

1141414.41 hits per line

Uncovered Existing Lines

Lines Coverage ∆ File
1
81.99
0.0% crates/circuit/src/parameter/parameter_expression.rs
6
92.29
-0.77% crates/qasm2/src/lex.rs
6
97.56
0.0% crates/qasm2/src/parse.rs
11
72.94
-0.45% crates/circuit/src/parameter/symbol_expr.rs
Jobs
ID Job ID Ran Files Coverage
1 19511142843.1 19 Nov 2025 06:30PM UTC 875
88.22
GitHub Action Run
Source Files on build 19511142843
  • Tree
  • List 875
  • Changed 8
  • Source Changed 1
  • Coverage Changed 8
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • Github Actions Build #19511142843
  • 536371c7 on github
  • Prev Build on gh-readonly-queue/main/pr-15205-81d885478c02138accc6dd0ecaffe3d6086ada6d (#19481919812)
  • Next Build on main (#19515383041)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc