Revision: 8e58a3206236
Author: Pekka Klärck
Date: Fri Nov 18 14:38:12 2011
Log: moved creating statistics message from TestSuite to
TotalStatistics
http://code.google.com/p/robotframework/source/detail?r=8e58a3206236
Modified:
/src/robot/model/totalstatistics.py
/src/robot/result/testsuite.py
=======================================
--- /src/robot/model/totalstatistics.py Fri Nov 18 13:46:12 2011
+++ /src/robot/model/totalstatistics.py Fri Nov 18 14:38:12 2011
@@ -16,7 +16,6 @@
from .visitor import SuiteVisitor
-
class TotalStatistics(object):
def __init__(self):
@@ -29,6 +28,21 @@
def __iter__(self):
return iter([self.critical, self.all])
+ def __unicode__(self):
+ return unicode(str(self))
+
+ def __str__(self):
+ ctotal, cend, cpass, cfail = self._get_counts(self.critical)
+ atotal, aend, apass, afail = self._get_counts(self.all)
+ return ('%d critical test%s, %d passed, %d failed\n'
+ '%d test%s total, %d passed, %d failed'
+ % (ctotal, cend, cpass, cfail, atotal, aend, apass, afail))
+
+ def _get_counts(self, stat):
+ ending = 's' if stat.total != 1 else ''
+ return stat.total, ending, stat.passed, stat.failed
+
+
class TotalStatisticsBuilder(SuiteVisitor):
=======================================
--- /src/robot/result/testsuite.py Fri Nov 18 13:46:12 2011
+++ /src/robot/result/testsuite.py Fri Nov 18 14:38:12 2011
@@ -40,31 +40,21 @@
def statistics(self):
return TotalStatisticsBuilder(self).stats
+ # TODO:
+ # 1) Remove critical_stats and all_stats in favor of new
self.statistics.xxx
+ # 2) Consider removing stat_message in favor of
unicode(self.statistics)
+
@property
def stat_message(self):
- return self._stat_message()
+ return unicode(self.statistics)
@property
def full_message(self):
- stat_msg = self._stat_message()
+ stat_msg = unicode(self.statistics)
if not self.message:
return stat_msg
return '%s\n\n%s' % (self.message, stat_msg)
- def _stat_message(self):
- # TODO: Should create self.statistics and move this there.
- ctotal, cend, cpass, cfail = self._get_counts(self.critical_stats)
- atotal, aend, apass, afail = self._get_counts(self.all_stats)
- return ('%d critical test%s, %d passed, %d failed\n'
- '%d test%s total, %d passed, %d failed'
- % (ctotal, cend, cpass, cfail, atotal, aend, apass, afail))
-
- def _get_counts(self, stat):
- ending = utils.plural_or_not(stat.total)
- return stat.total, ending, stat.passed, stat.failed
-
- # TODO: Remove critical_stats and all_stats in favor of new statistics
-
@property
def critical_stats(self):
return self.statistics.critical