diff --git a/CHANGES.rst b/CHANGES.rst index ce4b4926c..0b51a2538 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -25,12 +25,16 @@ Unreleased use ``--format=markdown`` to get the table in Markdown format, thanks to Steve Oswald in `pull 1479`_, closing `issue 1418`_. +- An empty file has a coverage total of 100%, but used to fail with + ``--fail-under``. This has been fixed, closing `issue 1470`_. + - Fixed a mis-measurement of a strange use of wildcard alternatives in match/case statements, closing `issue 1421`_. .. _pull 1479: https://github.com/nedbat/coveragepy/pull/1479 .. _issue 1418: https://github.com/nedbat/coveragepy/issues/1418 .. _issue 1421: https://github.com/nedbat/coveragepy/issues/1421 +.. _issue 1470: https://github.com/nedbat/coveragepy/issues/1470 .. _changes_6-6-0b1: diff --git a/coverage/summary.py b/coverage/summary.py index d1919e714..194dc1afa 100644 --- a/coverage/summary.py +++ b/coverage/summary.py @@ -165,7 +165,7 @@ def report(self, morfs, outfile=None): else: self.tabular_report() - return self.total.n_statements and self.total.pc_covered + return self.total.pc_covered def tabular_report(self): """Writes tabular report formats.""" diff --git a/tests/test_process.py b/tests/test_process.py index b76846e51..1f134a6da 100644 --- a/tests/test_process.py +++ b/tests/test_process.py @@ -1093,7 +1093,8 @@ def test_report(self): st, _ = self.run_command_status("coverage run empty.py") assert st == 0 st, _ = self.run_command_status("coverage report") - assert st == 2 + # An empty file is marked as 100% covered, so this is ok. + assert st == 0 @pytest.mark.skipif(env.WINDOWS, reason="Windows can't delete the directory in use.")