How to use the pycobertura.utils.memoize function in pycobertura

To help you get started, we’ve selected a few pycobertura examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aconrad / pycobertura / pycobertura / cobertura.py View on Github external
    @memoize
    def _get_class_element_by_filename(self, filename):
        syntax = "./packages//class[@filename='%s'][1]" % (filename)
        return self.xml.xpath(syntax)[0]
github aconrad / pycobertura / pycobertura / cobertura.py View on Github external
    @memoize
    def source_lines(self, filename):
        """
        Return a list for source lines of file `filename`.
        """
        with self.filesystem.open(filename) as f:
            return f.readlines()
github aconrad / pycobertura / pycobertura / cobertura.py View on Github external
    @memoize
    def file_source(self, filename):
        """
        Return a list of namedtuple `Line` for each line of code found in the
        source file with the given `filename`.
        """
        lines = []
        try:
            with self.filesystem.open(filename) as f:
                line_statuses = dict(self.line_statuses(filename))
                for lineno, source in enumerate(f, start=1):
                    line_status = line_statuses.get(lineno)
                    line = Line(lineno, source, line_status, None)
                    lines.append(line)

        except self.filesystem.FileNotFound as file_not_found:
            lines.append(Line(0, "%s not found" % file_not_found.path, None, None))
github aconrad / pycobertura / pycobertura / cobertura.py View on Github external
    @memoize
    def hit_statements(self, filename):
        """
        Return a list of covered line numbers for each of the hit statements
        found for the file `filename`.
        """
        el = self._get_class_element_by_filename(filename)
        lines = el.xpath("./lines/line[@hits>0]")
        return [int(line.attrib["number"]) for line in lines]
github aconrad / pycobertura / pycobertura / cobertura.py View on Github external
    @memoize
    def files(self):
        """
        Return the list of available files in the coverage report.
        """
        # maybe replace with a trie at some point? see has_file FIXME
        already_seen = set()
        filenames = []

        for el in self.xml.xpath("//class"):
            filename = el.attrib["filename"]
            if filename in already_seen:
                continue
            already_seen.add(filename)
            filenames.append(filename)

        return filenames
github aconrad / pycobertura / pycobertura / cobertura.py View on Github external
    @memoize
    def packages(self):
        """
        Return the list of available packages in the coverage report.
        """
        return [el.attrib["name"] for el in self.xml.xpath("//package")]
github aconrad / pycobertura / pycobertura / cobertura.py View on Github external
    @memoize
    def _get_lines_by_filename(self, filename):
        el = self._get_class_element_by_filename(filename)
        return el.xpath("./lines/line")
github aconrad / pycobertura / pycobertura / cobertura.py View on Github external
    @memoize
    def missed_statements(self, filename):
        """
        Return a list of uncovered line numbers for each of the missed
        statements found for the file `filename`.
        """
        el = self._get_class_element_by_filename(filename)
        lines = el.xpath("./lines/line[@hits=0]")
        return [int(l.attrib["number"]) for l in lines]