Skip to content

Fix tox coverage reporting#112

Closed
ngoldbaum wants to merge 1 commit into
Quansight-Labs:mainfrom
ngoldbaum:fix-coverage
Closed

Fix tox coverage reporting#112
ngoldbaum wants to merge 1 commit into
Quansight-Labs:mainfrom
ngoldbaum:fix-coverage

Conversation

@ngoldbaum

@ngoldbaum ngoldbaum commented Aug 11, 2025

Copy link
Copy Markdown
Collaborator

Before:

=================================================================== tests coverage ====================================================================
________________________________________________ coverage: platform darwin, python 3.14.0-candidate-1 _________________________________________________

Coverage LCOV written to file coverage.lcov

With this PR:

=================================================================== tests coverage ====================================================================
________________________________________________ coverage: platform darwin, python 3.14.0-candidate-1 _________________________________________________

Name                                                                                       Stmts   Miss  Cover
--------------------------------------------------------------------------------------------------------------
.tox/py314t/lib/python3.14t/site-packages/pytest_run_parallel/__init__.py                      0      0   100%
.tox/py314t/lib/python3.14t/site-packages/pytest_run_parallel/cpu_detection.py                29     14    52%
.tox/py314t/lib/python3.14t/site-packages/pytest_run_parallel/plugin.py                      211     47    78%
.tox/py314t/lib/python3.14t/site-packages/pytest_run_parallel/thread_comparator.py            52     14    73%
.tox/py314t/lib/python3.14t/site-packages/pytest_run_parallel/thread_unsafe_detection.py     187     41    78%
.tox/py314t/lib/python3.14t/site-packages/pytest_run_parallel/utils.py                        24      6    75%
tests/conftest.py                                                                              1      0   100%
tests/test_cpu_detection.py                                                                   61     26    57%
tests/test_run_parallel.py                                                                   119      2    98%
tests/test_thread_comparator.py                                                                4      0   100%
tests/test_thread_unsafe_detection.py                                                        116      4    97%
--------------------------------------------------------------------------------------------------------------
TOTAL                                                                                        804    154    81%

Seems a lot nicer! Also the way it's currently configured will only get the coverage for the plugin implementation correct for an editable install. With this change it'll always be correct for all installs.

@nickodell

Copy link
Copy Markdown
Contributor

The one issue I see is that it reports lines that are executed on import as being un-covered.

/home/nodell/pytest-run-parallel/.tox/py39/lib/python3.9/site-packages/coverage/inorout.py:525: CoverageWarning: Module pytest_run_parallel was previously imported, but not measured (module-not-measured)
  self.warn(msg, slug="module-not-measured")

For example, in the coverage report (if you change term to term-missing) it reports pytest_run_parallel/thread_unsafe_detection.py:118 as being uncovered, because the method definition is not executed after import.

The pytest-cov package authors have some suggestions about measuring the coverage of a pytest plugin here: pytest-dev/pytest-cov#455 (comment) and here: https://pytest-cov.readthedocs.io/en/latest/plugins.html

What do you think about an approach that runs the coverage command externally, like this? main...nickodell:pytest-run-parallel:njo-measure-coverage This changes the test coverage of thread_unsafe_detection.py from 78% to 93%, so it seems significant in practice.

@ngoldbaum

Copy link
Copy Markdown
Collaborator Author

Closing in favor of #113

@ngoldbaum ngoldbaum closed this Aug 11, 2025
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