coveragepy
coveragepy copied to clipboard
Prevent plugin dependencies in "omit" from causing already-imported warnings
I came across the same bug noted in this comment when using django plugin alongside both source/include and omit would cause a bunch of already-imported warnings for the plugin's dependencies:
Coverage.py warning: Already imported a file that will be measured: .../venv/lib/python3.7/site-packages/django/template/__init__.py (already-imported)
Coverage.py warning: Already imported a file that will be measured: .../venv/lib/python3.7/site-packages/django/template/engine.py (already-imported)
Coverage.py warning: Already imported a file that will be measured: .../venv/lib/python3.7/site-packages/django/template/base.py (already-imported)
Coverage.py warning: Already imported a file that will be measured: .../venv/lib/python3.7/site-packages/django/template/context.py (already-imported)
Coverage.py warning: Already imported a file that will be measured: .../venv/lib/python3.7/site-packages/django/template/exceptions.py (already-imported)
Coverage.py warning: Already imported a file that will be measured: .../venv/lib/python3.7/site-packages/django/template/library.py (already-imported)
Coverage.py warning: Already imported a file that will be measured: .../venv/lib/python3.7/site-packages/django/template/utils.py (already-imported)
Coverage.py warning: Already imported a file that will be measured: .../venv/lib/python3.7/site-packages/django/template/defaulttags.py (already-imported)
Coverage.py warning: Already imported a file that will be measured: .../venv/lib/python3.7/site-packages/django/template/defaultfilters.py (already-imported)
Coverage.py warning: Already imported a file that will be measured: .../venv/lib/python3.7/site-packages/django/template/smartif.py (already-imported)
Coverage.py warning: Already imported a file that will be measured: .../venv/lib/python3.7/site-packages/django/templatetags/__init__.py (already-imported)
Coverage.py warning: Already imported a file that will be measured: .../venv/lib/python3.7/site-packages/django/templatetags/i18n.py (already-imported)
I tried to fix this from the plugin side, but the only place the plugin gets an opinion is in the plugin's file_tracer()
method, and we can't disable tracing for the core django templates, otherwise we can't trace the templates themselves.
Every other omit_match
check is used too late, after plugins have already imported their dependencies
Codecov Report
Merging #1044 into master will decrease coverage by
0.02%
. The diff coverage is100.00%
.
@@ Coverage Diff @@
## master #1044 +/- ##
==========================================
- Coverage 93.97% 93.95% -0.03%
==========================================
Files 179 179
Lines 25140 25164 +24
Branches 2613 2615 +2
==========================================
+ Hits 23626 23642 +16
- Misses 1210 1218 +8
Partials 304 304
Impacted Files | Coverage Δ | |
---|---|---|
coverage/inorout.py | 74.07% <100.00%> (+0.29%) |
:arrow_up: |
tests/test_plugins.py | 99.25% <100.00%> (+0.01%) |
:arrow_up: |
tests/test_debug.py | 90.82% <0.00%> (-7.34%) |
:arrow_down: |
test_plugins.py | 98.76% <0.00%> (+0.02%) |
:arrow_up: |
inorout.py | 70.37% <0.00%> (+0.33%) |
:arrow_up: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 3274cba...42928bf. Read the comment docs.
Sorry, this has taken a while to get to. Thanks for providing a test! But I tried running the test without your fix, and it didn't fail. Does it fail for you?
Sorry about that, I was probably blindly chasing coverage 😄
I've added a new failing test case, you can see it fail with the already-imported
warning in CI https://github.com/nedbat/coveragepy/runs/1851303652#step:7:108
Ugh, I'm sorry, I forgot you had fixed this problem. I fixed it in a different way for https://github.com/nedbat/coveragepy/issues/1150. Does it solve the problem for you?
Since there has been no response, are we good to close this?
Apologies for keeping this open, if I recall correctly I think I had found a different workaround by changing which options I was using and forgot to test the new fix. I'll close now