Skip to content

pytest-cov > 7.0.0 breaks coverage generation for notebooks only #137

Description

@MarkusZimmerDLR

Dear nbmake-folks,

Not sure whether this is a nbmake issue. However, since this only occurs when testing jupyther notebooks, with nbmake, I figured I put it here and might as well document it for others.
Normal testing with pytest and pytest-cov is unaffected.

Description

Running
pytest -v --nbmake --cov=somepackage somenotebook.ipynb

results in an error:

<...>lib/python3.13/site-packages/coverage/inorout.py:521: CoverageWarning: Module somepackage was never imported. (module-not-imported); see https://coverage.readthedocs.io/en/7.10.7/messages.html#warning-module-not-imported

Downgrading pytest-cov to < 7.0.0 resolves that error.

Package Versions

uv pip list | grep -E "nbmake|nbclient|ipykernel|pytest|pytest-cov|coverage|nbformat|pygments"

Using Python 3.13.7 environment at: <...>
accessible-pygments           0.0.5
coverage                      7.10.7
ipykernel                     6.30.1
ipython-pygments-lexers       1.1.1
jupyterlab-pygments           0.3.0
nbclient                      0.10.2
nbformat                      5.10.4
nbmake                        1.5.5
pygments                      2.19.2
pytest                        8.4.2
pytest-cov                    7.0.0
`.coveragerc` content:
[run]
relative_files = True

source =
  src/
  */site-packages/

omit =
    */test/*
    */doc/*
    */__internals/*
    */conda.recipe/*
    */.html
    */.txt


concurrency =
  thread
  #multiprocessing # leads to a plethora of issues an lower coverage

parallel = True
sigterm = True

[paths]
source =
  src/
  */site-packages/

[report]
omit =
    */test/*
    */doc/*
    */__internals/*
    */conda.recipe/*
    */*.html
    */*txt

Cheers,
Markus

Activity

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions