Skip to content

--fail-under X where X > 0 should pass on files with no statements #1470

@CobaltCause

Description

@CobaltCause

Describe the bug
If I have a file with no statements, coverage report correctly says that the coverage is 100%. However, coverage report --fail-under 100 will fail because it thinks the coverage is 0%.

To Reproduce

  1. Use Python 3.10
  2. Use Coverage 6.4.4 with C extension
$ touch test.py
$ coverage run test.py
$ coverage report
Name      Stmts   Miss  Cover
-----------------------------
test.py       0      0   100%
-----------------------------
TOTAL         0      0   100%
$ echo $?
0
$ coverage report --fail-under 100
Name      Stmts   Miss  Cover
-----------------------------
test.py       0      0   100%
-----------------------------
TOTAL         0      0   100%
Coverage failure: total of 0 is less than fail-under=100
$ echo $?
2

Expected behavior
I would expect this to succeed with no error, it says right above that the coverage is 100%, but then claims it's 0% when --fail-under is supplied.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfixed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions