657 def save(self): |
657 def save(self): |
658 """Save the collected coverage data to the data file.""" |
658 """Save the collected coverage data to the data file.""" |
659 data = self.get_data() |
659 data = self.get_data() |
660 data.write() |
660 data.write() |
661 |
661 |
662 def combine(self, data_paths=None, strict=False): |
662 def combine(self, data_paths=None, strict=False, keep=False): |
663 """Combine together a number of similarly-named coverage data files. |
663 """Combine together a number of similarly-named coverage data files. |
664 |
664 |
665 All coverage data files whose name starts with `data_file` (from the |
665 All coverage data files whose name starts with `data_file` (from the |
666 coverage() constructor) will be read, and combined together into the |
666 coverage() constructor) will be read, and combined together into the |
667 current measurements. |
667 current measurements. |
672 directory) will be combined. |
672 directory) will be combined. |
673 |
673 |
674 If `strict` is true, then it is an error to attempt to combine when |
674 If `strict` is true, then it is an error to attempt to combine when |
675 there are no data files to combine. |
675 there are no data files to combine. |
676 |
676 |
|
677 If `keep` is true, then original input data files won't be deleted. |
|
678 |
677 .. versionadded:: 4.0 |
679 .. versionadded:: 4.0 |
678 The `data_paths` parameter. |
680 The `data_paths` parameter. |
679 |
681 |
680 .. versionadded:: 4.3 |
682 .. versionadded:: 4.3 |
681 The `strict` parameter. |
683 The `strict` parameter. |
682 |
684 |
|
685 .. versionadded: 5.5 |
|
686 The `keep` parameter. |
683 """ |
687 """ |
684 self._init() |
688 self._init() |
685 self._init_data(suffix=None) |
689 self._init_data(suffix=None) |
686 self._post_init() |
690 self._post_init() |
687 self.get_data() |
691 self.get_data() |
692 for paths in self.config.paths.values(): |
696 for paths in self.config.paths.values(): |
693 result = paths[0] |
697 result = paths[0] |
694 for pattern in paths[1:]: |
698 for pattern in paths[1:]: |
695 aliases.add(pattern, result) |
699 aliases.add(pattern, result) |
696 |
700 |
697 combine_parallel_data(self._data, aliases=aliases, data_paths=data_paths, strict=strict) |
701 combine_parallel_data( |
|
702 self._data, |
|
703 aliases=aliases, |
|
704 data_paths=data_paths, |
|
705 strict=strict, |
|
706 keep=keep, |
|
707 ) |
698 |
708 |
699 def get_data(self): |
709 def get_data(self): |
700 """Get the collected data. |
710 """Get the collected data. |
701 |
711 |
702 Also warn about various problems collecting data. |
712 Also warn about various problems collecting data. |
953 |
963 |
954 """ |
964 """ |
955 with override_config(self, |
965 with override_config(self, |
956 ignore_errors=ignore_errors, report_omit=omit, report_include=include, |
966 ignore_errors=ignore_errors, report_omit=omit, report_include=include, |
957 html_dir=directory, extra_css=extra_css, html_title=title, |
967 html_dir=directory, extra_css=extra_css, html_title=title, |
958 skip_covered=skip_covered, show_contexts=show_contexts, report_contexts=contexts, |
968 html_skip_covered=skip_covered, show_contexts=show_contexts, report_contexts=contexts, |
959 skip_empty=skip_empty, precision=precision, |
969 html_skip_empty=skip_empty, precision=precision, |
960 ): |
970 ): |
961 reporter = HtmlReporter(self) |
971 reporter = HtmlReporter(self) |
962 return reporter.report(morfs) |
972 return reporter.report(morfs) |
963 |
973 |
964 def xml_report( |
974 def xml_report( |