Skip to content

Add --no-skip-covered to allow negation of --skip-covered #932

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions coverage/cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down Expand Up @@ -360,6 +364,7 @@ def get_prog_name(self):
Opts.omit,
Opts.show_contexts,
Opts.skip_covered,
Opts.no_skip_covered,
Opts.skip_empty,
Opts.title,
] + GLOBAL_ARGS,
Expand Down Expand Up @@ -397,6 +402,7 @@ def get_prog_name(self):
Opts.omit,
Opts.show_missing,
Opts.skip_covered,
Opts.no_skip_covered,
Opts.skip_empty,
] + GLOBAL_ARGS,
usage="[options] [modules]",
Expand Down
30 changes: 30 additions & 0 deletions tests/test_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,36 @@ def not_covered():
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
Expand Down