Option to omit empty files (e.g. __init__.py)

Issue #315 resolved
Daniel Hahler created an issue

It would be nice if empty files (especially __init__.py) could be ignored, e.g. via an option omit-empty.

Ref: https://bitbucket.org/ned/coveragepy/issue/1/empty-initpy-files-are-reported-as-1

Comments (4)

  1. Alexander Walters

    The referenced issue is resolved, and I have not seen empty files as being reported. Coverage covers lines, if there are no lines, then there is nothing to hit or miss with. I think you have stumbled onto either a new bug or found some smell in your own code.

  2. Ned Batchelder repo owner

    @sdamon Issue #1 was about empty files claiming to have one statement, the fix made them have zero statements, but they are still reported. I suspect @blueyed is using the --source option, which makes completely unexecuted files appear in reports. I like the idea of skipping empty files if they are pulled in via the --source switch.

  3. Ned Batchelder repo owner

    Changeset b7762d1a6614 introduces the report --skip-covered option, which will skip any file with 100% coverage. Since empty __init__.py files are 100% covered, does this satisfy your use case?

  4. Log in to comment