Qiskit / qiskit

Qiskit is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives.
https://www.ibm.com/quantum/qiskit
Apache License 2.0
5.23k stars 2.36k forks source link

Integrating test suite into qiskit module #4738

Closed JohanNicander closed 4 years ago

JohanNicander commented 4 years ago

What is the expected enhancement?

The qiskit test suite should be integrated into the qiskit module. This would ease the integration of qiskit into more exotic hardware (see the qiskit-on-raspberry project for an example).

Examples of functionality would be

python -c 'import qiskit; qiskit.test()'

to run the full test suite, or

python -c 'import qiskit.circuits; qiskit.circuits.test()'

to test only the circuits submodule.

This should preferably be implemented without changing the current testing functionality or without having to rewrite any of the tests.

This can be done by moving the testes from the "external" (external to the qiskit module) test folder and move them into the module itself. To be consistent the best solution would probably be to let every module and submodule handle their tests. That is split up the existing test directory and distribute it over the modules. To make the tests runnable from python without having to implement the functionality in every module/submodule a top-level tester class can be utilized to let modules register that they are testable and let it handle it. This also allows for easy and consistent migration and behavior for all other qiskit elements. I have made a minimal example of how this would look, which can be found here.

Furthermore, I have completed the test migration on a local copy of qiskit-terra (with surprising ease) and plan to implement the top-level tester class shortly, as proof of concept. This repo can be made available on request.

mtreinish commented 4 years ago

I think this is a duplicate of #1389

JohanNicander commented 4 years ago

You are absolutely right! My bad!