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

Fix pytest test collection on default install #749

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cdanis
Copy link

@cdanis cdanis commented Mar 7, 2025

As is, with a default poetry install, a simple poetry pytest run will encouter import errors while reading the test files themselves -- which causes pytest to fatally error during test collection, meaning no tests are run.

As is, with a default `poetry install`, a simple `poetry pytest run`
will encouter import errors while reading the test files themselves --
which causes pytest to fatally error during test collection, meaning no
tests are run.
@dougtoppin
Copy link

dougtoppin commented Mar 7, 2025

As a test, I opened the PR into a gitpod workspace and did the following.
Note that both --all-groups and --all-extras were necessary to get all tests to pass.
If either were not included test failures did occur.

  • poetry install --all-groups
  • poetry install --all-extras
  • poetry run pytest

Got the following output from pytest:

============================================================================ test session starts =============================================================================
platform linux -- Python 3.12.9, pytest-8.3.3, pluggy-1.5.0
rootdir: /workspace/meshtastic-python
configfile: pytest.ini
plugins: anyio-4.6.2.post1, cov-5.0.0, hypothesis-6.119.1, dash-2.18.2
collected 306 items / 75 deselected / 231 selected                                                                                                                           

meshtastic/tests/test_analysis.py .                                                                                                                                    [  0%]
meshtastic/tests/test_init.py ...                                                                                                                                      [  1%]
meshtastic/tests/test_main.py ............................................................................                                                             [ 34%]
meshtastic/tests/test_mesh_interface.py ...............................................                                                                                [ 54%]
meshtastic/tests/test_node.py ....................                                                                                                                     [ 63%]
meshtastic/tests/test_remote_hardware.py .......                                                                                                                       [ 66%]
meshtastic/tests/test_serial_interface.py ...                                                                                                                          [ 67%]
meshtastic/tests/test_stream_interface.py ..                                                                                                                           [ 68%]
meshtastic/tests/test_tcp_interface.py ...                                                                                                                             [ 70%]
meshtastic/tests/test_tunnel.py ..............                                                                                                                         [ 76%]
meshtastic/tests/test_util.py .......................................................                                                                                  [100%]

==================================================================== 231 passed, 75 deselected in 21.27s =====================================================================

Workspace details:

  • Ubuntu 22.04.5 LTS
  • Python 3.12.9
  • Poetry (version 2.0.1)
  • pytest 8.3.3

I had a suggestion if there is interest.
It can be helpful with PRs to include a few more details.
This is useful for people both to know how it was tested and as a reference for people submitting future PRs to know how they should test.
A pull request template md can be created which gives a new submitter a starting point for what to do.
That template could include environment and version information, steps that were performed, and expected output/results.
It might also include a description of unit or other tests that were added.

I am not sure if this is helpful or not, but I have found this useful in the past and it can reduce review time.

Copy link

codecov bot commented Mar 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 60.14%. Comparing base (ed908fc) to head (b42d338).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #749   +/-   ##
=======================================
  Coverage   60.14%   60.14%           
=======================================
  Files          24       24           
  Lines        4062     4062           
=======================================
  Hits         2443     2443           
  Misses       1619     1619           
Flag Coverage Δ
unittests 60.14% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cdanis
Copy link
Author

cdanis commented Mar 8, 2025

As discussed on Discord, I'll also create new pytest markers for analytics, powermon, and tunnel, and make them default-excluded (like the other ones with 'optional dependencies' like "two radios connected over USB" are).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants