Tessera: Quantum Circuit Transpiler

Running Tests

Tessera has a full pytest suite targeting 100% coverage across all application code. Tests live in the tests/ directory with one file per module. This page covers how to run the suite, how to read the output, and what the coverage targets are.

Prerequisites

Dev dependencies must be installed. If you haven't already:

pip install -e .[dev]

This installs pytest, pytest-cov, and qiskit-aer alongside the runtime dependencies.

Running the Suite

Full suite with coverage report:

pytest tests/ --cov=. --cov-report=term-missing

Full suite without coverage:

pytest tests/

Single test file:

pytest tests/test_converters.py --cov=. --cov-report=term-missing

HTML coverage report:

pytest tests/ --cov=. --cov-report=html

Opens htmlcov/index.html in your browser for a full visual breakdown per file.

Understanding the Output

Test results:

tests/test_converters.py .....   [ 43%]
  • .: passing test
  • F: failing test
  • E: test errored out (unexpected exception)
  • The percentage shows overall progress through the suite

Coverage table:

Name                    Stmts   Miss  Cover   Missing
-----------------------------------------------------
tessera/converters.py      28      1    96%   19
  • Stmts: total executable lines in the file
  • Miss: lines not executed during tests
  • Cover: percentage of lines covered
  • Missing: specific line numbers not covered

Coverage Targets

The target is 100% coverage across all application code. The one known and expected exception is noted below.

FileTargetNotes
circuit.py100%
instruction.py100%
gate_library.py100%
converters.py100%
pass_manager.py100%
transpiler.py100%
transpiler_pass.py89%Abstract method miss is expected: see below
hardware/coupling_map.py100%
api/transpile.py100%
backends/basis_gate_sets.py100%
backends/decomposition_maps.py100%
backends/backend_registry.py100%
passes/basis_translation_pass.py100%
passes/dense_layout_pass.py100%
passes/basic_swap_router.py100%
passes/remove_barriers_pass.py100%
passes/cancel_adjacent_pass.py100%
passes/merge_rotations_pass.py100%
passes/trivial_pass.py100%
passes/identity_pass.py100%
test.py0%This file is itself a test script, so there is no need to test it

What to Ignore

transpiler_pass.py line 24: the pass statement inside the abstract run() method. Subclasses always override it so it is never executed by design. The 89% coverage on this file is expected and can be ignored.

Test files themselves: coverage on test files will always show 100% and can be ignored. They are not application code.

Adding Tests for New Code

When you add a new pass or module, create a corresponding test_<module_name>.py in tests/. At minimum cover:

  • Happy path: expected transformation occurs
  • No-op case: circuit that should not change stays unchanged
  • Edge cases: empty circuit, single instruction, measurements only
  • Any exceptions the code raises

See Adding a Pass or Adding a Backend for specific test patterns for each.