def _analyze(self, it): """Analyze a single morf or code unit. Returns an `Analysis` object. """ if not isinstance(it, CodeUnit): it = code_unit_factory(it, self.file_locator)[0] return Analysis(self, it)
def _analyze(self, it): """Analyze a single morf or code unit. Returns an `Analysis` object. """ self.get_data() if not isinstance(it, FileReporter): it = self._get_file_reporter(it) return Analysis(self.data, it)
def _analyze(self, it): """Analyze a single morf or code unit. Returns an `Analysis` object. """ self._harvest_data() if not isinstance(it, CodeUnit): get_ext = self.data.extension_data().get it = code_unit_factory(it, self.file_locator, get_ext)[0] return Analysis(self, it)
def _analyze(self, it): """Analyze a single morf or code unit. Returns an `Analysis` object. """ # All reporting comes through here, so do reporting initialization. self._init() self._post_init() data = self.get_data() if not isinstance(it, FileReporter): it = self._get_file_reporter(it) return Analysis(data, self.config.precision, it, self._file_mapper)
def _analyze(self, it): """Analyze a single morf or code unit. Returns an `Analysis` object. """ def get_plugin(filename): """For code_unit_factory to use to find the plugin for a file.""" plugin = None plugin_name = self.data.plugin_data().get(filename) if plugin_name: plugin = self.plugins.get(plugin_name) return plugin self._harvest_data() if not isinstance(it, CodeUnit): it = code_unit_factory(it, self.file_locator, get_plugin)[0] return Analysis(self, it)
def _analyze(self, it): """Analyze a single morf or code unit. Returns an `Analysis` object. """ if not isinstance(it, CodeUnit): it = code_unit_factory(it, self.file_locator)[0] try: a = Analysis(self, it) return a except NotPython: try: if isinstance(it, CodeUnit): it.name = it.filename return DjangoTemplateAnalysis(self, it) except: traceback.print_exc()
error_string = ''.join([repr(error) for error in test_result.errors]) assert len(test_result.errors) == 0,\ "ERROR: UNIT TESTS FAILED, PLEASE FIX BEFORE RUNNING COVERAGE:\n%s\n%s" % (output_stream.getvalue(), error_string) output_stream.close() cov.stop() print("Generating HTML report") cov.html_report(directory='coverage') print("Aggregating package stats") total_numbers = {} # Package name -> (Numbers: package coverage stats, dict: files per coverage bin) for filename in cov.get_data().measured_files(): file_reporter = PythonFileReporter(filename, cov) analysis = Analysis(cov.get_data(), file_reporter, abs_file) # If the package name does not contain more than 2 parts, it's a top-level file. package_path = pathlib.Path(relative_filename(filename)) package = ".".join(package_path.parts[:2 if len(package_path.parts) > 2 else 1]) package_stats = total_numbers.get(package) # Put all exactly 100% coverage files into the 80%-100% bin individual_coverage = min(4, int(analysis.numbers.pc_covered / 20.0)) if not package_stats: total_numbers[package] = (analysis.numbers, {individual_coverage: 1}) else: package_numbers, package_buckets = package_stats package_buckets[individual_coverage] = 1 + package_buckets.get(individual_coverage, 0) total_numbers[package] = (package_numbers + analysis.numbers, package_buckets)
def _analyze(self, it): self._harvest_data() if not isinstance(it, CodeUnit): it = code_unit_factory(it, self.file_locator)[0] return Analysis(self, it)