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

Coverage and diffcov tests are unreliable #304

Closed
jaraco opened this issue Mar 21, 2024 · 2 comments
Closed

Coverage and diffcov tests are unreliable #304

jaraco opened this issue Mar 21, 2024 · 2 comments

Comments

@jaraco
Copy link
Member

jaraco commented Mar 21, 2024

“Collateral” tests fail with:

importlib_resources/functional.py (62.5%): Missing lines 3,5,8,11,16,23,28,35,40,48,63,78
importlib_resources/tests/test_functional.py (98.2%): Missing lines 7,9

These are top-level statements (mostly def), and an alternate import for old Python versions.

Originally posted by @encukou in #303 (comment)

@jaraco
Copy link
Member Author

jaraco commented Mar 21, 2024

They're unfortunately inaccurate because pytest (or a plugin or one of the dependencies) imports importlib_resources prior to starting up coverage, so any lines "executed" at coverage time get "missed". I did some more digging and found that pytest enabler unconditionally imports importlib_resources, probably because it takes advantage of features in importlib_resources 5.10, which didn't land in CPython until 3.12. There may be other plugins implicated too.

@jaraco
Copy link
Member Author

jaraco commented Mar 21, 2024

I've released a new pytest-enabler 3.1, which relies on the stdlib for importlib_resources in Python 3.12. Now when running the tests, they show a much more accurate picture of the coverage (on Python 3.12+). This issue still affects other dependencies used by pytest-enabler (jaraco.context, jaraco.functools). I've opened pytest-dev/pytest-cov#635 to track a more comprehensive solution, but I'm closing this for now.

@jaraco jaraco closed this as completed Mar 21, 2024
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

No branches or pull requests

1 participant