summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Sottile <asottile@umich.edu>2020-02-14 14:33:52 -0800
committerAnthony Sottile <asottile@umich.edu>2020-02-14 14:34:31 -0800
commitf7dd8845e9589a3622207dc6e3173e372857a2b5 (patch)
tree2633e2dd8aeae566c95d29e6afb82b7ca969e115
parent1c5f6610f987cc6fd7c575fac45470b91a72b731 (diff)
downloadpython-coveragepy-git-f7dd8845e9589a3622207dc6e3173e372857a2b5.tar.gz
Add --no-skip-covered to allow negation of --skip-covered
-rw-r--r--coverage/cmdline.py6
-rw-r--r--tests/test_summary.py30
2 files changed, 36 insertions, 0 deletions
diff --git a/coverage/cmdline.py b/coverage/cmdline.py
index 9fddb6bb..e57870ff 100644
--- a/coverage/cmdline.py
+++ b/coverage/cmdline.py
@@ -93,6 +93,10 @@ class Opts(object):
'--skip-covered', action='store_true',
help="Skip files with 100% coverage.",
)
+ no_skip_covered = optparse.make_option(
+ '--no-skip-covered', action='store_false', dest='skip_covered',
+ help="Disable --skip-covered.",
+ )
skip_empty = optparse.make_option(
'--skip-empty', action='store_true',
help="Skip files with no code.",
@@ -360,6 +364,7 @@ CMDS = {
Opts.omit,
Opts.show_contexts,
Opts.skip_covered,
+ Opts.no_skip_covered,
Opts.skip_empty,
Opts.title,
] + GLOBAL_ARGS,
@@ -397,6 +402,7 @@ CMDS = {
Opts.omit,
Opts.show_missing,
Opts.skip_covered,
+ Opts.no_skip_covered,
Opts.skip_empty,
] + GLOBAL_ARGS,
usage="[options] [modules]",
diff --git a/tests/test_summary.py b/tests/test_summary.py
index ab6414af..7c70d7ff 100644
--- a/tests/test_summary.py
+++ b/tests/test_summary.py
@@ -300,6 +300,36 @@ class SummaryTest(UsingModulesMixin, CoverageTest):
self.assertEqual(squeezed[6], "1 file skipped due to complete coverage.")
self.assertEqual(self.last_command_status, 0)
+ def test_report_no_skip_covered(self):
+ self.make_file("main.py", """
+ import not_covered
+
+ def normal():
+ print("z")
+ normal()
+ """)
+ self.make_file("not_covered.py", """
+ def not_covered():
+ print("n")
+ """)
+ self.omit_site_packages()
+ out = self.run_command("coverage run main.py")
+ self.assertEqual(out, "z\n")
+ report = self.report_from_command("coverage report --skip-covered --no-skip-covered")
+
+ # Name Stmts Miss Cover
+ # ------------------------------------
+ # main.py 4 0 100%
+ # not_covered.py 2 1 50%
+ # ------------------------------------
+ # TOTAL 6 1 83%
+
+ self.assertEqual(self.line_count(report), 6, report)
+ squeezed = self.squeezed_lines(report)
+ self.assertEqual(squeezed[2], "main.py 4 0 100%")
+ self.assertEqual(squeezed[3], "not_covered.py 2 1 50%")
+ self.assertEqual(squeezed[5], "TOTAL 6 1 83%")
+
def test_report_skip_covered_branches(self):
self.make_file("main.py", """
import not_covered, covered