Commits

cpopa  committed 9b7b0f0

Order of reporting is consistent.

  • Participants
  • Parent commits ac05ff5

Comments (0)

Files changed (2)

 
     * Emit 'catching-non-exception' for non-class nodes. Closes issue #303.
 
+    * Order of reporting is consistent.
+
 
 2014-07-26  --  1.3.0
 
         self._reports = {}
         self._reports_state = {}
 
+    @property
+    def _sorted_reports(self):
+        """ Return a list of reports, sorted in the order
+        of their reporting priority.
+        """
+        reports = sorted(self._reports, key=lambda x: getattr(x, 'name', ''))
+        try:
+            # Remove the current reporter and add it
+            # at the end of the list.
+            reports.pop(reports.index(self))
+        except ValueError:
+            pass
+        reports.append(self)
+        return reports
+
     def register_report(self, reportid, r_title, r_cb, checker):
         """register a report
 
         """render registered reports"""
         sect = Section('Report',
                        '%s statements analysed.'% (self.stats['statement']))
-        for checker in self._reports:
+        for checker in self._sorted_reports:
             for reportid, r_title, r_cb in self._reports[checker]:
                 if not self.report_is_enabled(reportid):
                     continue