230 Defaults are initialized for all options. |
230 Defaults are initialized for all options. |
231 |
231 |
232 """ |
232 """ |
233 |
233 |
234 def __init__(self, *args, **kwargs): |
234 def __init__(self, *args, **kwargs): |
235 super().__init__( |
235 super().__init__(add_help_option=False, *args, **kwargs) |
236 add_help_option=False, *args, **kwargs |
|
237 ) |
|
238 self.set_defaults( |
236 self.set_defaults( |
239 # Keep these arguments alphabetized by their names. |
237 # Keep these arguments alphabetized by their names. |
240 action=None, |
238 action=None, |
241 append=None, |
239 append=None, |
242 branch=None, |
240 branch=None, |
646 debug=debug, |
644 debug=debug, |
647 concurrency=concurrency, |
645 concurrency=concurrency, |
648 check_preimported=True, |
646 check_preimported=True, |
649 context=options.context, |
647 context=options.context, |
650 messages=not options.quiet, |
648 messages=not options.quiet, |
651 ) |
649 ) |
652 |
650 |
653 if options.action == "debug": |
651 if options.action == "debug": |
654 return self.do_debug(args) |
652 return self.do_debug(args) |
655 |
653 |
656 elif options.action == "erase": |
654 elif options.action == "erase": |
673 morfs=unglob_args(args), |
671 morfs=unglob_args(args), |
674 ignore_errors=options.ignore_errors, |
672 ignore_errors=options.ignore_errors, |
675 omit=omit, |
673 omit=omit, |
676 include=include, |
674 include=include, |
677 contexts=contexts, |
675 contexts=contexts, |
678 ) |
676 ) |
679 |
677 |
680 # We need to be able to import from the current directory, because |
678 # We need to be able to import from the current directory, because |
681 # plugins may try to, for example, to read Django settings. |
679 # plugins may try to, for example, to read Django settings. |
682 sys.path.insert(0, '') |
680 sys.path.insert(0, '') |
683 |
681 |
690 show_missing=options.show_missing, |
688 show_missing=options.show_missing, |
691 skip_covered=options.skip_covered, |
689 skip_covered=options.skip_covered, |
692 skip_empty=options.skip_empty, |
690 skip_empty=options.skip_empty, |
693 sort=options.sort, |
691 sort=options.sort, |
694 **report_args |
692 **report_args |
695 ) |
693 ) |
696 elif options.action == "annotate": |
694 elif options.action == "annotate": |
697 self.coverage.annotate(directory=options.directory, **report_args) |
695 self.coverage.annotate(directory=options.directory, **report_args) |
698 elif options.action == "html": |
696 elif options.action == "html": |
699 total = self.coverage.html_report( |
697 total = self.coverage.html_report( |
700 directory=options.directory, |
698 directory=options.directory, |
702 skip_covered=options.skip_covered, |
700 skip_covered=options.skip_covered, |
703 skip_empty=options.skip_empty, |
701 skip_empty=options.skip_empty, |
704 show_contexts=options.show_contexts, |
702 show_contexts=options.show_contexts, |
705 title=options.title, |
703 title=options.title, |
706 **report_args |
704 **report_args |
707 ) |
705 ) |
708 elif options.action == "xml": |
706 elif options.action == "xml": |
709 total = self.coverage.xml_report( |
707 total = self.coverage.xml_report( |
710 outfile=options.outfile, |
708 outfile=options.outfile, |
711 skip_empty=options.skip_empty, |
709 skip_empty=options.skip_empty, |
712 **report_args |
710 **report_args |
713 ) |
711 ) |
714 elif options.action == "json": |
712 elif options.action == "json": |
715 total = self.coverage.json_report( |
713 total = self.coverage.json_report( |
716 outfile=options.outfile, |
714 outfile=options.outfile, |
717 pretty_print=options.pretty_print, |
715 pretty_print=options.pretty_print, |
718 show_contexts=options.show_contexts, |
716 show_contexts=options.show_contexts, |
719 **report_args |
717 **report_args |
720 ) |
718 ) |
721 elif options.action == "lcov": |
719 elif options.action == "lcov": |
722 total = self.coverage.lcov_report( |
720 total = self.coverage.lcov_report( |
723 outfile=options.outfile, |
721 outfile=options.outfile, |
724 **report_args |
722 **report_args |
725 ) |
723 ) |
726 else: |
724 else: |
727 # There are no other possible actions. |
725 # There are no other possible actions. |
728 raise AssertionError |
726 raise AssertionError |
729 |
727 |
730 if total is not None: |
728 if total is not None: |