Skip to content

Commit bf8cbe1

Browse files
committed
fix: more cleanup of --data-file options
1 parent f9a5451 commit bf8cbe1

File tree

3 files changed

+88
-43
lines changed

3 files changed

+88
-43
lines changed

coverage/cmdline.py

+18-11
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class Opts:
6262
combine_datafile = optparse.make_option(
6363
'', '--data-file', action='store', metavar="DATAFILE",
6464
help=(
65-
"Base name of the data files to combine and write. " +
65+
"Base name of the data files to operate on. " +
6666
"Defaults to '.coverage'. [env: COVERAGE_FILE]"
6767
),
6868
)
@@ -344,17 +344,16 @@ def get_prog_name(self):
344344
Opts.rcfile,
345345
]
346346

347-
REPORT_ARGS = [Opts.input_datafile]
348-
349347
CMDS = {
350348
'annotate': CmdOptionParser(
351349
"annotate",
352350
[
353351
Opts.directory,
352+
Opts.input_datafile,
354353
Opts.ignore_errors,
355354
Opts.include,
356355
Opts.omit,
357-
] + REPORT_ARGS + GLOBAL_ARGS,
356+
] + GLOBAL_ARGS,
358357
usage="[options] [modules]",
359358
description=(
360359
"Make annotated copies of the given files, marking statements that are executed " +
@@ -366,9 +365,9 @@ def get_prog_name(self):
366365
"combine",
367366
[
368367
Opts.append,
368+
Opts.combine_datafile,
369369
Opts.keep,
370370
Opts.quiet,
371-
Opts.combine_datafile
372371
] + GLOBAL_ARGS,
373372
usage="[options] <path1> <path2> ... <pathN>",
374373
description=(
@@ -396,7 +395,10 @@ def get_prog_name(self):
396395
),
397396

398397
'erase': CmdOptionParser(
399-
"erase", [Opts.input_datafile] + GLOBAL_ARGS,
398+
"erase",
399+
[
400+
Opts.combine_datafile
401+
] + GLOBAL_ARGS,
400402
description="Erase previously collected coverage data.",
401403
),
402404

@@ -411,6 +413,7 @@ def get_prog_name(self):
411413
[
412414
Opts.contexts,
413415
Opts.directory,
416+
Opts.input_datafile,
414417
Opts.fail_under,
415418
Opts.ignore_errors,
416419
Opts.include,
@@ -422,7 +425,7 @@ def get_prog_name(self):
422425
Opts.no_skip_covered,
423426
Opts.skip_empty,
424427
Opts.title,
425-
] + REPORT_ARGS + GLOBAL_ARGS,
428+
] + GLOBAL_ARGS,
426429
usage="[options] [modules]",
427430
description=(
428431
"Create an HTML report of the coverage of the files. " +
@@ -435,6 +438,7 @@ def get_prog_name(self):
435438
"json",
436439
[
437440
Opts.contexts,
441+
Opts.input_datafile,
438442
Opts.fail_under,
439443
Opts.ignore_errors,
440444
Opts.include,
@@ -443,14 +447,15 @@ def get_prog_name(self):
443447
Opts.json_pretty_print,
444448
Opts.quiet,
445449
Opts.show_contexts,
446-
] + REPORT_ARGS + GLOBAL_ARGS,
450+
] + GLOBAL_ARGS,
447451
usage="[options] [modules]",
448452
description="Generate a JSON report of coverage results.",
449453
),
450454

451455
'lcov': CmdOptionParser(
452456
"lcov",
453457
[
458+
Opts.input_datafile,
454459
Opts.fail_under,
455460
Opts.ignore_errors,
456461
Opts.include,
@@ -466,6 +471,7 @@ def get_prog_name(self):
466471
"report",
467472
[
468473
Opts.contexts,
474+
Opts.input_datafile,
469475
Opts.fail_under,
470476
Opts.ignore_errors,
471477
Opts.include,
@@ -476,7 +482,7 @@ def get_prog_name(self):
476482
Opts.skip_covered,
477483
Opts.no_skip_covered,
478484
Opts.skip_empty,
479-
] + REPORT_ARGS + GLOBAL_ARGS,
485+
] + GLOBAL_ARGS,
480486
usage="[options] [modules]",
481487
description="Report coverage statistics on modules.",
482488
),
@@ -488,10 +494,10 @@ def get_prog_name(self):
488494
Opts.branch,
489495
Opts.concurrency,
490496
Opts.context,
497+
Opts.output_datafile,
491498
Opts.include,
492499
Opts.module,
493500
Opts.omit,
494-
Opts.output_datafile,
495501
Opts.pylib,
496502
Opts.parallel_mode,
497503
Opts.source,
@@ -504,14 +510,15 @@ def get_prog_name(self):
504510
'xml': CmdOptionParser(
505511
"xml",
506512
[
513+
Opts.input_datafile,
507514
Opts.fail_under,
508515
Opts.ignore_errors,
509516
Opts.include,
510517
Opts.omit,
511518
Opts.output_xml,
512519
Opts.quiet,
513520
Opts.skip_empty,
514-
] + REPORT_ARGS + GLOBAL_ARGS,
521+
] + GLOBAL_ARGS,
515522
usage="[options] [modules]",
516523
description="Generate an XML report of coverage results.",
517524
),

doc/cmd.rst

+33-31
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ There are many options:
134134
Valid values are: eventlet, gevent, greenlet,
135135
multiprocessing, thread, or a comma-list of them.
136136
--context=LABEL The context label to record for this coverage run.
137+
--data-file=OUTFILE Write the recorded coverage data to this file.
138+
Defaults to '.coverage'. [env: COVERAGE_FILE]
137139
--include=PAT1,PAT2,...
138140
Include only files whose paths match one of these
139141
patterns. Accepts shell-style wildcards, which must be
@@ -142,8 +144,6 @@ There are many options:
142144
path, to be run as 'python -m' would run it.
143145
--omit=PAT1,PAT2,... Omit files whose paths match one of these patterns.
144146
Accepts shell-style wildcards, which must be quoted.
145-
--data-file=OUTFILE Write the recorded coverage data to this file.
146-
Defaults to '.coverage'. [env: COVERAGE_FILE]
147147
-L, --pylib Measure coverage even inside the Python installed
148148
library, which isn't done by default.
149149
-p, --parallel-mode Append the machine name, process id and random number
@@ -160,7 +160,7 @@ There are many options:
160160
--rcfile=RCFILE Specify configuration file. By default '.coveragerc',
161161
'setup.cfg', 'tox.ini', and 'pyproject.toml' are
162162
tried. [env: COVERAGE_RCFILE]
163-
.. [[[end]]] (checksum: 3ec48d96422f8b3aed3cf5a8b223891f)
163+
.. [[[end]]] (checksum: 05d15818e42e6f989c42894fb2b3c753)
164164
165165
If you want :ref:`branch coverage <branch>` measurement, use the ``--branch``
166166
flag. Otherwise only statement coverage is measured.
@@ -391,18 +391,18 @@ want to keep those files, use the ``--keep`` command-line option.
391391
Options:
392392
-a, --append Append coverage data to .coverage, otherwise it starts
393393
clean each time.
394+
--data-file=DATAFILE Base name of the data files to operate on. Defaults to
395+
'.coverage'. [env: COVERAGE_FILE]
394396
--keep Keep original coverage files, otherwise they are
395397
deleted.
396398
-q, --quiet Don't print messages about what is happening.
397-
--data-file=DATAFILE Base name of the data files to combine and write.
398-
Defaults to '.coverage'. [env: COVERAGE_FILE]
399399
--debug=OPTS Debug options, separated by commas. [env:
400400
COVERAGE_DEBUG]
401401
-h, --help Get help on this command.
402402
--rcfile=RCFILE Specify configuration file. By default '.coveragerc',
403403
'setup.cfg', 'tox.ini', and 'pyproject.toml' are
404404
tried. [env: COVERAGE_RCFILE]
405-
.. [[[end]]] (checksum: 6cba18a0531f9d2f7af67e472b96eb6b)
405+
.. [[[end]]] (checksum: 0ac91b0781d7146b87953f09090dab92)
406406
407407
408408
.. _cmd_erase:
@@ -421,15 +421,15 @@ To erase the collected data, use the **erase** command:
421421
Erase previously collected coverage data.
422422
423423
Options:
424-
--data-file=INFILE Read coverage data for report generation from this file.
425-
Defaults to '.coverage'. [env: COVERAGE_FILE]
426-
--debug=OPTS Debug options, separated by commas. [env:
427-
COVERAGE_DEBUG]
428-
-h, --help Get help on this command.
429-
--rcfile=RCFILE Specify configuration file. By default '.coveragerc',
430-
'setup.cfg', 'tox.ini', and 'pyproject.toml' are tried.
431-
[env: COVERAGE_RCFILE]
432-
.. [[[end]]] (checksum: e3dec8ef7687d3525682904340e8cf54)
424+
--data-file=DATAFILE Base name of the data files to operate on. Defaults to
425+
'.coverage'. [env: COVERAGE_FILE]
426+
--debug=OPTS Debug options, separated by commas. [env:
427+
COVERAGE_DEBUG]
428+
-h, --help Get help on this command.
429+
--rcfile=RCFILE Specify configuration file. By default '.coveragerc',
430+
'setup.cfg', 'tox.ini', and 'pyproject.toml' are
431+
tried. [env: COVERAGE_RCFILE]
432+
.. [[[end]]] (checksum: cfeaef66ce8d5154dc6914831030b46b)
433433
434434
If your configuration file indicates parallel data collection, **erase** will
435435
remove all of the data files.
@@ -496,6 +496,8 @@ as a percentage.
496496
Only display data from lines covered in the given
497497
contexts. Accepts Python regexes, which must be
498498
quoted.
499+
--data-file=INFILE Read coverage data for report generation from this
500+
file. Defaults to '.coverage'. [env: COVERAGE_FILE]
499501
--fail-under=MIN Exit with a status of 2 if the total coverage is less
500502
than MIN.
501503
-i, --ignore-errors Ignore errors while reading source files.
@@ -514,15 +516,13 @@ as a percentage.
514516
--skip-covered Skip files with 100% coverage.
515517
--no-skip-covered Disable --skip-covered.
516518
--skip-empty Skip files with no code.
517-
--data-file=INFILE Read coverage data for report generation from this
518-
file. Defaults to '.coverage'. [env: COVERAGE_FILE]
519519
--debug=OPTS Debug options, separated by commas. [env:
520520
COVERAGE_DEBUG]
521521
-h, --help Get help on this command.
522522
--rcfile=RCFILE Specify configuration file. By default '.coveragerc',
523523
'setup.cfg', 'tox.ini', and 'pyproject.toml' are
524524
tried. [env: COVERAGE_RCFILE]
525-
.. [[[end]]] (checksum: 97565fdb6f1eefbeeb12d56151fa5e63)
525+
.. [[[end]]] (checksum: 2f8dde61bab2f44fbfe837aeae87dfd2)
526526
527527
The ``-m`` flag also shows the line numbers of missing statements::
528528

@@ -613,6 +613,8 @@ Click the keyboard icon in the upper right to see the complete list.
613613
quoted.
614614
-d DIR, --directory=DIR
615615
Write the output files to DIR.
616+
--data-file=INFILE Read coverage data for report generation from this
617+
file. Defaults to '.coverage'. [env: COVERAGE_FILE]
616618
--fail-under=MIN Exit with a status of 2 if the total coverage is less
617619
than MIN.
618620
-i, --ignore-errors Ignore errors while reading source files.
@@ -630,15 +632,13 @@ Click the keyboard icon in the upper right to see the complete list.
630632
--no-skip-covered Disable --skip-covered.
631633
--skip-empty Skip files with no code.
632634
--title=TITLE A text string to use as the title on the HTML.
633-
--data-file=INFILE Read coverage data for report generation from this
634-
file. Defaults to '.coverage'. [env: COVERAGE_FILE]
635635
--debug=OPTS Debug options, separated by commas. [env:
636636
COVERAGE_DEBUG]
637637
-h, --help Get help on this command.
638638
--rcfile=RCFILE Specify configuration file. By default '.coveragerc',
639639
'setup.cfg', 'tox.ini', and 'pyproject.toml' are
640640
tried. [env: COVERAGE_RCFILE]
641-
.. [[[end]]] (checksum: e3208f3b38a44ca81e0235e867f4fd1c)
641+
.. [[[end]]] (checksum: e3a1a6e24ad9b303ba06d42880ed0219)
642642
643643
The title of the report can be set with the ``title`` setting in the
644644
``[html]`` section of the configuration file, or the ``--title`` switch on
@@ -691,6 +691,8 @@ compatible with `Cobertura`_.
691691
Generate an XML report of coverage results.
692692
693693
Options:
694+
--data-file=INFILE Read coverage data for report generation from this
695+
file. Defaults to '.coverage'. [env: COVERAGE_FILE]
694696
--fail-under=MIN Exit with a status of 2 if the total coverage is less
695697
than MIN.
696698
-i, --ignore-errors Ignore errors while reading source files.
@@ -704,15 +706,13 @@ compatible with `Cobertura`_.
704706
'coverage.xml'
705707
-q, --quiet Don't print messages about what is happening.
706708
--skip-empty Skip files with no code.
707-
--data-file=INFILE Read coverage data for report generation from this
708-
file. Defaults to '.coverage'. [env: COVERAGE_FILE]
709709
--debug=OPTS Debug options, separated by commas. [env:
710710
COVERAGE_DEBUG]
711711
-h, --help Get help on this command.
712712
--rcfile=RCFILE Specify configuration file. By default '.coveragerc',
713713
'setup.cfg', 'tox.ini', and 'pyproject.toml' are
714714
tried. [env: COVERAGE_RCFILE]
715-
.. [[[end]]] (checksum: 3dc4450c0a723109f987c4b6f968be43)
715+
.. [[[end]]] (checksum: 8b239d89534be0b2c69489e10b1352a9)
716716
717717
You can specify the name of the output file with the ``-o`` switch.
718718

@@ -777,6 +777,8 @@ The **json** command writes coverage data to a "coverage.json" file.
777777
Only display data from lines covered in the given
778778
contexts. Accepts Python regexes, which must be
779779
quoted.
780+
--data-file=INFILE Read coverage data for report generation from this
781+
file. Defaults to '.coverage'. [env: COVERAGE_FILE]
780782
--fail-under=MIN Exit with a status of 2 if the total coverage is less
781783
than MIN.
782784
-i, --ignore-errors Ignore errors while reading source files.
@@ -791,15 +793,13 @@ The **json** command writes coverage data to a "coverage.json" file.
791793
--pretty-print Format the JSON for human readers.
792794
-q, --quiet Don't print messages about what is happening.
793795
--show-contexts Show contexts for covered lines.
794-
--data-file=INFILE Read coverage data for report generation from this
795-
file. Defaults to '.coverage'. [env: COVERAGE_FILE]
796796
--debug=OPTS Debug options, separated by commas. [env:
797797
COVERAGE_DEBUG]
798798
-h, --help Get help on this command.
799799
--rcfile=RCFILE Specify configuration file. By default '.coveragerc',
800800
'setup.cfg', 'tox.ini', and 'pyproject.toml' are
801801
tried. [env: COVERAGE_RCFILE]
802-
.. [[[end]]] (checksum: fdc9af899380fbb78599d08a70e564fc)
802+
.. [[[end]]] (checksum: e53e60cb65d971c35d1db1c08324b72e)
803803
804804
You can specify the name of the output file with the ``-o`` switch. The JSON
805805
can be nicely formatted by specifying the ``--pretty-print`` switch.
@@ -820,6 +820,8 @@ The **lcov** command writes coverage data to a "coverage.lcov" file.
820820
Generate an LCOV report of coverage results.
821821
822822
Options:
823+
--data-file=INFILE Read coverage data for report generation from this
824+
file. Defaults to '.coverage'. [env: COVERAGE_FILE]
823825
--fail-under=MIN Exit with a status of 2 if the total coverage is less
824826
than MIN.
825827
-i, --ignore-errors Ignore errors while reading source files.
@@ -838,7 +840,7 @@ The **lcov** command writes coverage data to a "coverage.lcov" file.
838840
--rcfile=RCFILE Specify configuration file. By default '.coveragerc',
839841
'setup.cfg', 'tox.ini', and 'pyproject.toml' are
840842
tried. [env: COVERAGE_RCFILE]
841-
.. [[[end]]] (checksum: 4d078e4637e5b507cbb997803a0d4758)
843+
.. [[[end]]] (checksum: 16acfbae8011d2e3b620695c5fe13746)
842844
843845
Other common reporting options are described above in :ref:`cmd_reporting`.
844846

@@ -890,22 +892,22 @@ For example::
890892
Options:
891893
-d DIR, --directory=DIR
892894
Write the output files to DIR.
895+
--data-file=INFILE Read coverage data for report generation from this
896+
file. Defaults to '.coverage'. [env: COVERAGE_FILE]
893897
-i, --ignore-errors Ignore errors while reading source files.
894898
--include=PAT1,PAT2,...
895899
Include only files whose paths match one of these
896900
patterns. Accepts shell-style wildcards, which must be
897901
quoted.
898902
--omit=PAT1,PAT2,... Omit files whose paths match one of these patterns.
899903
Accepts shell-style wildcards, which must be quoted.
900-
--data-file=INFILE Read coverage data for report generation from this
901-
file. Defaults to '.coverage'. [env: COVERAGE_FILE]
902904
--debug=OPTS Debug options, separated by commas. [env:
903905
COVERAGE_DEBUG]
904906
-h, --help Get help on this command.
905907
--rcfile=RCFILE Specify configuration file. By default '.coveragerc',
906908
'setup.cfg', 'tox.ini', and 'pyproject.toml' are
907909
tried. [env: COVERAGE_RCFILE]
908-
.. [[[end]]] (checksum: aa41bad1cd4c08efc3276b5dca01dea3)
910+
.. [[[end]]] (checksum: fd7d8fbd2dd6e24d37f868b389c2ad6d)
909911
910912
Other common reporting options are described above in :ref:`cmd_reporting`.
911913

0 commit comments

Comments
 (0)