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

Adjust how unit tests are referencing module #49

Merged
merged 3 commits into from
Oct 18, 2024

Conversation

kingsleyadam
Copy link
Owner

@kingsleyadam kingsleyadam commented Oct 18, 2024

This PR adjusts how unit tests are run against the PyPi module. Previously I was referencing the abbfreeathome module, which requires you to install the module e.g. abbfreeathome.api import FreeAtHomeApi.

Instead, if I adjust the test pythonpath pytest option I can reference the module relative to the root path e.g. src.abbfreeathome.api import FreeAtHomeApi. This will run the tests against the files in the repo directly, instead of the installed module.

This has a number of benefits.

  • Don't have to install the module in your python environment everytime you want to run a test.
  • Natively works in Visual Studio Code, no need to run any Terminal Commands. This includes code coverage in Visual Studio Code.

I also adjusted the launch.json config to add a new debug configuration. This will allow you to Debug tests and step into the module code. This is much needed when attempting to figure out why a test isn't working, or why the test coverage isn't hitting all code paths.

Visual Studio Code

Run Tests

Screenshot 2024-10-18 at 12 03 30

Run Tests With Coverage

Screenshot 2024-10-18 at 12 04 21

@kingsleyadam kingsleyadam added the bug Something isn't working label Oct 18, 2024
@kingsleyadam kingsleyadam merged commit 434e737 into main Oct 18, 2024
8 checks passed
@kingsleyadam kingsleyadam deleted the u/kingsleyadam/adjustUnitTests branch October 18, 2024 10:13
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

Successfully merging this pull request may close these issues.

1 participant