Skip to content

Commit d00f254

Browse files
committed
Simplify testing of --no-skip-covered, and add docs
1 parent 2c6c421 commit d00f254

File tree

4 files changed

+18
-31
lines changed

4 files changed

+18
-31
lines changed

CHANGES.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ Unreleased
3232
``--precision`` option to control the number of decimal points displayed.
3333
Thanks, Teake Nutma (`pull request 982`_).
3434

35+
- The ``coverage report`` command now accepts a ``--no-skip-covered`` option
36+
to negate ``--skip-covered``. Thanks, Anthony Sottile (`issue 779`_ and
37+
`pull request 932`_).
38+
3539
- If coverage fails due to the coverage total not reaching the ``--fail-under``
3640
value, it will now print a message making the condition clear. Thanks,
3741
Naveen Yadav (`pull request 977`_).
@@ -44,8 +48,10 @@ Unreleased
4448
considered.
4549

4650
.. _pull request 931: https://github.com/nedbat/coveragepy/pull/931
51+
.. _pull request 932: https://github.com/nedbat/coveragepy/pull/932
4752
.. _pull request 977: https://github.com/nedbat/coveragepy/pull/977
4853
.. _pull request 982: https://github.com/nedbat/coveragepy/pull/982
54+
.. _issue 779: https://github.com/nedbat/coveragepy/issues/779
4955
.. _issue 858: https://github.com/nedbat/coveragepy/issues/858
5056
.. _issue 990: https://github.com/nedbat/coveragepy/issues/990
5157

doc/cmd.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,8 @@ command line::
364364
TOTAL 76 10 87%
365365

366366
The ``--skip-covered`` switch will skip any file with 100% coverage, letting
367-
you focus on the files that still need attention. The ``--skip-empty`` switch
367+
you focus on the files that still need attention. The ``--no-skip-covered``
368+
option can be used if needed to see all the files. The ``--skip-empty`` switch
368369
will skip any file with no executable statements.
369370

370371
If you have :ref:`recorded contexts <contexts>`, the ``--contexts`` option lets

tests/test_cmdline.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,16 @@ def test_report(self):
382382
cov.load()
383383
cov.report(skip_covered=True)
384384
""")
385+
self.cmd_executes("report --skip-covered --no-skip-covered", """\
386+
cov = Coverage()
387+
cov.load()
388+
cov.report(skip_covered=False)
389+
""")
390+
self.cmd_executes("report --no-skip-covered", """\
391+
cov = Coverage()
392+
cov.load()
393+
cov.report(skip_covered=False)
394+
""")
385395
self.cmd_executes("report --skip-empty", """\
386396
cov = Coverage()
387397
cov.load()

tests/test_summary.py

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -300,36 +300,6 @@ def not_covered():
300300
self.assertEqual(squeezed[6], "1 file skipped due to complete coverage.")
301301
self.assertEqual(self.last_command_status, 0)
302302

303-
def test_report_no_skip_covered(self):
304-
self.make_file("main.py", """
305-
import not_covered
306-
307-
def normal():
308-
print("z")
309-
normal()
310-
""")
311-
self.make_file("not_covered.py", """
312-
def not_covered():
313-
print("n")
314-
""")
315-
self.omit_site_packages()
316-
out = self.run_command("coverage run main.py")
317-
self.assertEqual(out, "z\n")
318-
report = self.report_from_command("coverage report --skip-covered --no-skip-covered")
319-
320-
# Name Stmts Miss Cover
321-
# ------------------------------------
322-
# main.py 4 0 100%
323-
# not_covered.py 2 1 50%
324-
# ------------------------------------
325-
# TOTAL 6 1 83%
326-
327-
self.assertEqual(self.line_count(report), 6, report)
328-
squeezed = self.squeezed_lines(report)
329-
self.assertEqual(squeezed[2], "main.py 4 0 100%")
330-
self.assertEqual(squeezed[3], "not_covered.py 2 1 50%")
331-
self.assertEqual(squeezed[5], "TOTAL 6 1 83%")
332-
333303
def test_report_skip_covered_branches(self):
334304
self.make_file("main.py", """
335305
import not_covered, covered

0 commit comments

Comments
 (0)