Skip to content

Commit

Permalink
Add --precision switch to report command
Browse files Browse the repository at this point in the history
  • Loading branch information
Teake Nutma committed Apr 30, 2020
1 parent 444e596 commit bbd0c0f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions coverage/cmdline.py
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit bbd0c0f

Please sign in to comment.