Skip to content
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

Add --precision option to report command #982

Merged
merged 1 commit into from May 12, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions coverage/cmdline.py
Expand Up @@ -146,6 +146,13 @@ class Opts(object):
"to be run as 'python -m' would run it."
),
)
precision = optparse.make_option(
'', '--precision', action='store', metavar='N', type=int,
help=(
"Number of digits after the decimal point to display for "
"reported coverage percentages."
),
)
rcfile = optparse.make_option(
'', '--rcfile', action='store',
help=(
Expand Down Expand Up @@ -203,6 +210,7 @@ def __init__(self, *args, **kwargs):
omit=None,
contexts=None,
parallel_mode=None,
precision=None,
pylib=None,
rcfile=True,
show_missing=None,
Expand Down Expand Up @@ -395,6 +403,7 @@ def get_prog_name(self):
Opts.ignore_errors,
Opts.include,
Opts.omit,
Opts.precision,
Opts.show_missing,
Opts.skip_covered,
Opts.skip_empty,
Expand Down Expand Up @@ -569,6 +578,7 @@ def command_line(self, argv):
omit=omit,
include=include,
contexts=contexts,
precision=options.precision,
)

# We need to be able to import from the current directory, because
Expand Down
4 changes: 2 additions & 2 deletions coverage/control.py
Expand Up @@ -829,7 +829,7 @@ def _get_file_reporters(self, morfs=None):
def report(
self, morfs=None, show_missing=None, ignore_errors=None,
file=None, omit=None, include=None, skip_covered=None,
contexts=None, skip_empty=None,
contexts=None, skip_empty=None, precision=None,
):
"""Write a textual summary report to `file`.

Expand Down Expand Up @@ -873,7 +873,7 @@ def report(
self,
ignore_errors=ignore_errors, report_omit=omit, report_include=include,
show_missing=show_missing, skip_covered=skip_covered,
report_contexts=contexts, skip_empty=skip_empty,
report_contexts=contexts, skip_empty=skip_empty, precision=precision,
):
reporter = SummaryReporter(self)
return reporter.report(morfs, outfile=file)
Expand Down