Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests are difficult to run on an installed version of the package #896

Open
wshanks opened this issue Dec 24, 2022 · 0 comments
Open

Tests are difficult to run on an installed version of the package #896

wshanks opened this issue Dec 24, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@wshanks
Copy link
Collaborator

wshanks commented Dec 24, 2022

Information

  • Qiskit Metal version: 0.1.2
  • Python version: 3.10
  • Operating system: Linux

What is the current behavior?

The way the tests are structured right now makes it difficult to run all of them on an installed version of qiskit-metal.

The way the CI runs the tests is to run

python -m unittest

from the top level of the repo. Since qiskit_metal is in the top level (rather than using a src directory), the repo version of qiskit-metal gets imported by Python rather than the one in site-packages.

The tests are actually packaged inside of qiskit_metal.tests, so you can actually run most of the tests against the installed version of qiskit-metal by changing the working directory to something other than the top level of the repo and then running

python -m unittest discover qiskit_metal.tests

This will run the tests, but a few of them will fail because they to access qiskit_metal/tests/test_data which is not currently included in the package.

One can also try changing directory into qiskit_metal and running

python -m unittest discover tests

to avoid importing the repo qiskit_metal but some of the test code has relative imports out of the tests package to other parts of qiskit-metal so this also fails.

Steps to reproduce the problem

The problem is not being able to do something so it is hard to give a reproducer but some possible cases are given above. For testing a solution, one could:

  1. Install qiskit_metal
  2. Introduce a bug into the qiskit_metal in the repo
  3. Confirm that the tests still run without encountering the bug

What is the expected behavior?

There is a way to run the tests against the installed version of qiskit_metal.

Suggested solutions

There are a couple options:

  1. Include qiskit_metal/tests/test_data in the package. It is small in size compared to the tests files already included, though including test code in a package is not that common.
  2. Move the tests up out of qiskit_metal, so one could run them without needing to add the top level of the repo to the Python path. This would require a little bit of tweaking of the code because some imports assume the test files are inside of the qiskit_metal package.
@wshanks wshanks added the bug Something isn't working label Dec 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant