"Already imported" warning when used with django_coverage_plugin · Issue #1150 · nedbat/coveragepy (original) (raw)

Describe the bug

When using django_coverage_plugin (django-coverage-plugin==1.8.0) the following warnings are emitted even when using --source to specify a folder which does not contain the venv:

Coverage.py warning: Already imported a file that will be measured: c:\dev\scratch\coveragepy\venv\lib\site-packages\django\template\context.py (already-imported)
Coverage.py warning: Already imported a file that will be measured: c:\dev\scratch\coveragepy\venv\lib\site-packages\django\template\exceptions.py (already-imported)
Coverage.py warning: Already imported a file that will be measured: c:\dev\scratch\coveragepy\venv\lib\site-packages\django\template\base.py (already-imported)
Coverage.py warning: Already imported a file that will be measured: c:\dev\scratch\coveragepy\venv\lib\site-packages\django\template\library.py (already-imported)
Coverage.py warning: Already imported a file that will be measured: c:\dev\scratch\coveragepy\venv\lib\site-packages\django\template\engine.py (already-imported)
Coverage.py warning: Already imported a file that will be measured: c:\dev\scratch\coveragepy\venv\lib\site-packages\django\template\utils.py (already-imported)
Coverage.py warning: Already imported a file that will be measured: c:\dev\scratch\coveragepy\venv\lib\site-packages\django\template\backends\__init__.py (already-imported)
Coverage.py warning: Already imported a file that will be measured: c:\dev\scratch\coveragepy\venv\lib\site-packages\django\template\backends\base.py (already-imported)
Coverage.py warning: Already imported a file that will be measured: c:\dev\scratch\coveragepy\venv\lib\site-packages\django\template\backends\django.py (already-imported)
Coverage.py warning: Already imported a file that will be measured: c:\dev\scratch\coveragepy\venv\lib\site-packages\django\template\autoreload.py (already-imported)
Coverage.py warning: Already imported a file that will be measured: c:\dev\scratch\coveragepy\venv\lib\site-packages\django\template\__init__.py (already-imported)
Coverage.py warning: Already imported a file that will be measured: c:\dev\scratch\coveragepy\venv\lib\site-packages\django\template\defaultfilters.py (already-imported)
Coverage.py warning: Already imported a file that will be measured: c:\dev\scratch\coveragepy\venv\lib\site-packages\django\template\smartif.py (already-imported)
Coverage.py warning: Already imported a file that will be measured: c:\dev\scratch\coveragepy\venv\lib\site-packages\django\template\defaulttags.py (already-imported)
Coverage.py warning: Already imported a file that will be measured: c:\dev\scratch\coveragepy\venv\lib\site-packages\django\templatetags\__init__.py (already-imported)
Coverage.py warning: Already imported a file that will be measured: c:\dev\scratch\coveragepy\venv\lib\site-packages\django\templatetags\i18n.py (already-imported)

To Reproduce

  1. Python 3.8.5 (64 bit)
  2. pip freeze:
coverage==5.6b1

django-coverage-plugin==1.8.0
six==1.15.0

Django==3.2.0
sqlparse==0.4.1
asgiref==3.3.4
pytz==2021.1
  1. Minimum repro example attached as minimal_repro.zip
  2. Command run (in a py -m venv myvenv afer pip install -r requirements.txt)
coverage run --source=./code/ -m unittest discover ./code/

Expected behavior
Only see output from unit test, rather than 16 warnings which it is not obvious that I can fix.

Additional context
This sounds similar to #876 #905 #909 but doesn't seem to be fixed by any of them as it still occurs on coverage==5.6b1

If this bug report should be over on https://github.com/nedbat/django_coverage_plugin instead that's fine I'm happy to re-report it there - though given other "Already imported" warnings were fixed in coveragepy itself I thought I'd report here first.