Skip to content

Coverage and diffcov tests are unreliable #304

Closed

Description

@jaraco

“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)

Activity

  1. jaraco commented on Mar 21, 2024

    @jaraco
    MemberAuthor

    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.

  2. jaraco commented on Mar 21, 2024

    @jaraco
    MemberAuthor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions