-
Notifications
You must be signed in to change notification settings - Fork 213
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
coverage starts too late with warning filter #437
Comments
I guess this section should be extended to outline your usecase as well (it's the same solution): https://pytest-cov.readthedocs.io/en/latest/plugins.html |
Yeah, that might have helped. I definitely didn't think to look at that section. |
I wonder if there is a better solution possible.
|
Summary
When trying to get coverage on something like
myproject
, while also running a warning filter on a warning within that project, saymyproject.MyWarning
coverage is started too late. For example:will result in
myproject
being imported (to getMyWarning
), before pytest-cov starts coverage. Any imports (and code that runs at import time) as a results of importingmyproject
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.
The text was updated successfully, but these errors were encountered: