コード例 #1
0
    def dump_statistics(self, cov):
        """
        Dump test run statistics
        :param cov:
        :return:
        """
        from coverage.results import Numbers
        from coverage.report import Reporter
        from noc.tests.conftest import _stats as stats

        self.print("---[ Test session statistics ]------")
        cov.get_data()
        reporter = Reporter(cov, cov.config)
        totals = Numbers()
        for fr in reporter.find_file_reporters(None):
            analysis = cov._analyze(fr)
            totals += analysis.numbers
        n_passed = len(stats.get("passed", []))
        n_skipped = len(stats.get("skipped", []))
        n_error = len(stats.get("error", []))
        n_failed = len(stats.get("failed", []))
        if n_error or n_failed:
            status = "Failed"
        else:
            status = "Passed"
        self.print("Status              : %s" % status)
        self.print("Tests Passed:       : %s" % n_passed)
        self.print("Tests Skipped:      : %s" % n_skipped)
        self.print("Tests Failed:       : %s" % n_failed)
        self.print("Tests Error:        : %s" % n_error)
        self.print("Coverage            : %d%%" % totals.pc_covered)
        self.print("Coverage Statements : %s" % totals.n_statements)
        self.print("Coverage Missing    : %s" % totals.n_missing)
        self.print("Coverage Excluded   : %s" % totals.n_excluded)
コード例 #2
0
    def dump_idea_bookmarks(self, path):
        def is_project_path(p):
            return os.path.commonprefix([cwd, p]) == cwd

        from noc.tests.conftest import _stats as stats

        warnings = stats.get("warnings", [])
        r = []
        cwd = os.path.abspath(os.getcwd())
        lcwd = len(cwd)
        if not cwd.endswith(os.sep):
            lcwd += len(os.sep)
        for w in warnings:
            wp, line = w.fslocation
            if is_project_path(wp):
                r += [
                    '<bookmark url="file://$PROJECT_DIR$/%s" line="%d" />' %
                    (wp[lcwd:], line - 1)
                ]
        if not r:
            self.print("No warnings to dump as bookmarks")
            return
        self.print("Dumping %d IDEA bookmarks to %s" % (len(r), path))
        with open(path, "w") as f:
            f.write("\n".join(sorted(r)))
コード例 #3
0
 def dump_failed(self):
     """
     Dump failed tests list
     :return:
     """
     from noc.tests.conftest import _stats as stats
     failed = sorted(tr.nodeid for tr in stats.get("failed", []))
     if not failed:
         return
     self.print("---[ Failed tests ]------")
     self.print("\n".join(failed))