Skip to content

Regression: "Already imported a file that will be measured", loss of coverage #909

Closed
@mgedmin

Description

@mgedmin

Describe the bug

I'm measuring gtimelog's test coverage with coverage run -m gtimelog.tests. Since coverage 5.0a4 this is missing some coverage (shows 79% instead of 100%) and also produces warnings:

Coverage.py warning: Already imported a file that will be measured: /home/mg/src/gtimelog/src/gtimelog/__init__.py (already-imported)
Coverage.py warning: Already imported a file that will be measured: /home/mg/src/gtimelog/src/gtimelog/timelog.py (already-imported)
Coverage.py warning: Already imported a file that will be measured: /home/mg/src/gtimelog/src/gtimelog/settings.py (already-imported)

To Reproduce
How can we reproduce the problem? Please be specific.

  1. What version of Python are you using? 2.7.17 and 3.7.5

  2. What version of coverage.py are you using? 5.0.1 (but every version starting with 5.0a4 is affected; 5.0a3 is fine)

  3. What versions of what packages do you have installed?

    coverage==5.0.1
    coverage-python-version==0.2.0
    freezegun==0.3.12
    -e git+https://github.com/gtimelog/gtimelog@5f7858cc58925e42b2d7cbc1d872b11745c38872#egg=gtimelog
    mock==3.0.5
    python-dateutil==2.8.1
    six==1.13.0
    </details>
    
    
  4. What code are you running? Give us a specific commit of a specific repo that we can check out.
    https://github.com/gtimelog/gtimelog/tree/5f7858cc58925e42b2d7cbc1d872b11745c38872

  5. What commands did you run? make coverage for a quick version; .tox/coverage/bin/pip install coverage=$version && .tox/coverage/bin/coverage -m gtimelog.test && .tox/coverage/bin/coverage report to test a specific version of coverage.py

Expected behavior
100% coverage reported, no warnings.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfixed

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions