Skip to content

coverage starts too late with warning filter #437

Open
@dopplershift

Description

@dopplershift

Summary

When trying to get coverage on something like myproject, while also running a warning filter on a warning within that project, say myproject.MyWarning coverage is started too late. For example:

python -m pytest -W error::myproject.MyWarning --cov=myproject tests/

will result in myproject being imported (to get MyWarning), before pytest-cov starts coverage. Any imports (and code that runs at import time) as a results of importing myproject will be missed. You do get the warning: Coverage.py warning: Module myproject was previously imported, but not measured (module-not-measured)

I'm not sure if anything can be done about it (since pytest is the one controlling when warning filters are set up), but at the very least it would be great to put this as a gotcha in the docs somewhere.

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