3 new revisions:
Revision: 7c7087fe2ea6
Author: Janne Härkönen <[email protected]>
Date: Mon Nov 14 03:45:51 2011
Log: errors are now iterable
http://code.google.com/p/robotframework/source/detail?r=7c7087fe2ea6
Revision: afccb41de7ab
Author: Janne Härkönen <[email protected]>
Date: Mon Nov 14 03:46:38 2011
Log: Integrated new Statistics object
http://code.google.com/p/robotframework/source/detail?r=afccb41de7ab
Revision: 4606749b00d5
Author: Janne Härkönen <[email protected]>
Date: Mon Nov 14 03:47:59 2011
Log: Automated merge with https://code.google.com/p/robotframework/
http://code.google.com/p/robotframework/source/detail?r=4606749b00d5
==============================================================================
Revision: 7c7087fe2ea6
Author: Janne Härkönen <[email protected]>
Date: Mon Nov 14 03:45:51 2011
Log: errors are now iterable
http://code.google.com/p/robotframework/source/detail?r=7c7087fe2ea6
Modified:
/src/robot/result/executionerrors.py
=======================================
--- /src/robot/result/executionerrors.py Thu Nov 10 06:42:09 2011
+++ /src/robot/result/executionerrors.py Mon Nov 14 03:45:51 2011
@@ -25,8 +25,7 @@
self.messages.extend(other.messages)
def visit(self, visitor):
- # TODO: visiting logic should be moved into visitor
- visitor.start_errors()
- for message in self.messages:
- message.visit(visitor)
- visitor.end_errors()
+ visitor.visit_errors(self)
+
+ def __iter__(self):
+ return iter(self.messages)
==============================================================================
Revision: afccb41de7ab
Author: Janne Härkönen <[email protected]>
Date: Mon Nov 14 03:46:38 2011
Log: Integrated new Statistics object
http://code.google.com/p/robotframework/source/detail?r=afccb41de7ab
Modified:
/src/robot/model/statistics.py
/src/robot/result/executionresult.py
/src/robot/result/jsondatamodelhandlers.py
/src/robot/result/serializer.py
/src/robot/result/visitor.py
/utest/model/test_statistics.py
/utest/reporting/test_reporting.py
=======================================
--- /src/robot/model/statistics.py Fri Nov 11 04:50:57 2011
+++ /src/robot/model/statistics.py Mon Nov 14 03:46:38 2011
@@ -19,15 +19,32 @@
from robot.model.tags import TagPatterns
+class Statistics(object):
+
+ def __init__(self, suite, suite_stat_level=-1, tag_stat_include=None,
+ tag_stat_exclude=None, tag_stat_combine=None,
tag_doc=None,
+ tag_stat_link=None):
+ self.tags = TagStatistics(tag_stat_include, tag_stat_exclude,
+ tag_stat_combine, tag_doc, tag_stat_link)
+ self.suite = StatisticsBuilder(self.tags,
suite_stat_level).build(suite)
+ self.tags.sort()
+ self.total = TotalStatistics(self.suite)
+
+ def visit(self, visitor):
+ visitor.visit_statistics(self)
+
+
class StatisticsBuilder(SuiteVisitor):
- def __init__(self, tag_stats):
+ def __init__(self, tag_stats, suite_stat_level):
self._tag_stats = tag_stats
self._parents = []
+ self._suite_stat_level = suite_stat_level
def start_suite(self, suite):
new = SuiteStatistics(suite)
- self._current_suite_stat.suites.append(new)
+ if self._suite_stat_level == -1 or len(self._parents) <
self._suite_stat_level:
+ self._current_suite_stat.suites.append(new)
self._parents.append(self._current_suite_stat)
self._current_suite_stat = new
self._current_suite = suite
@@ -48,28 +65,6 @@
self._tag_stats.add_test(test, self._current_suite.critical)
-class Statistics(object):
-
- def __init__(self, suite, tag_stat_include=None, tag_stat_exclude=None,
- tag_stat_combine=None, tag_doc=None, tag_stat_link=None):
- self.tags = TagStatistics(tag_stat_include, tag_stat_exclude,
- tag_stat_combine, tag_doc, tag_stat_link)
- self.suite = StatisticsBuilder(self.tags).build(suite)
- self.tags.sort()
- self.total = TotalStatistics(self.suite)
-
- #TODO: Replace with visit
- def serialize(self, serializer):
- serializer.start_statistics(self)
- self.total.serialize(serializer)
- self.tags.serialize(serializer)
- self.suite.serialize(serializer)
- serializer.end_statistics(self)
-
- def visit(self, visitor):
- self.serialize(visitor)
-
-
class SuiteStatistics(object):
def __init__(self, suite):
@@ -82,6 +77,15 @@
if test.critical == 'yes':
self.critical.add_test(test)
+ def visit(self, visitor):
+ visitor.visit_suite_statistics(self)
+
+ def __iter__(self):
+ yield self.all
+ for s in self.suites:
+ for stat in s:
+ yield stat
+
class Stat(object):
@@ -89,6 +93,11 @@
self.name = name
self.passed = 0
self.failed = 0
+
+ @property
+ def _default_attrs(self):
+ return {'pass': str(self.passed),
+ 'fail': str(self.failed)}
@property
def total(self):
@@ -127,17 +136,21 @@
def __nonzero__(self):
return self.failed == 0
+ def visit(self, visitor):
+ visitor.visit_stat(self)
+
class SuiteStat(Stat):
type = 'suite'
def __init__(self, suite):
- Stat.__init__(self, suite.name)
- self.longname = suite.longname
+ Stat.__init__(self, suite.longname)
self.id = suite.id
-
- def serialize(self, serializer):
- serializer.suite_stat(self)
+ self._attrs = {'name': suite.name, 'idx': suite.id}
+
+ @property
+ def attrs(self):
+ return dict(self._default_attrs, **self._attrs) # TODO: idx -> id
class TagStat(Stat):
@@ -153,6 +166,25 @@
self.combined = combined
self.tests = []
+ @property
+ def attrs(self):
+ return dict(self._default_attrs, info=self._info,
links=self._links,
+ doc=self.doc, combined=self.combined)
+
+ @property
+ def _info(self):
+ if self.critical:
+ return 'critical'
+ if self.non_critical:
+ return 'non-critical'
+ if self.combined:
+ return 'combined'
+ return ''
+
+ @property
+ def _links(self):
+ return ':::'.join(':'.join([title, url]) for url, title in
self.links)
+
def add_test(self, test):
Stat.add_test(self, test)
self.tests.append(test)
@@ -166,9 +198,6 @@
return cmp(bool(other.combined), bool(self.combined))
return cmp(self.name, other.name)
- def serialize(self, serializer):
- serializer.tag_stat(self)
-
class TotalStat(Stat):
type = 'total'
@@ -178,8 +207,9 @@
self.passed = suite_stat.passed
self.failed = suite_stat.failed
- def serialize(self, serializer):
- serializer.total_stat(self)
+ @property
+ def attrs(self):
+ return self._default_attrs
class CombinedTag(object):
@@ -238,11 +268,11 @@
if comb.match(test.tags):
self.stats[comb.name].add_test(test)
- def serialize(self, serializer):
- serializer.start_tag_stats(self)
- for stat in sorted(self.stats.values()):
- stat.serialize(serializer)
- serializer.end_tag_stats(self)
+ def visit(self, visitor):
+ visitor.visit_tag_statistics(self)
+
+ def __iter__(self):
+ return iter(sorted(self.stats.values()))
def sort(self):
# TODO: Is this needed?
@@ -256,11 +286,11 @@
self.critical = TotalStat('Critical Tests', suite.critical)
self.all = TotalStat('All Tests', suite.all)
- def serialize(self, serializer):
- serializer.start_total_stats(self)
- self.critical.serialize(serializer)
- self.all.serialize(serializer)
- serializer.end_total_stats(self)
+ def visit(self, visitor):
+ visitor.visit_total_statistics(self)
+
+ def __iter__(self):
+ return iter([self.critical, self.all])
class TagStatInfo:
=======================================
--- /src/robot/result/executionresult.py Thu Nov 10 06:42:09 2011
+++ /src/robot/result/executionresult.py Mon Nov 14 03:46:38 2011
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from robot.common.statistics import Statistics
+from robot.model.statistics import Statistics
from configurer import SuiteConfigurer
from testsuite import TestSuite
=======================================
--- /src/robot/result/jsondatamodelhandlers.py Thu Nov 10 06:42:09 2011
+++ /src/robot/result/jsondatamodelhandlers.py Mon Nov 14 03:46:38 2011
@@ -15,6 +15,7 @@
from robot import utils
from robot.output import LEVELS
from robot.result import TestSuite, Keyword, TestCase
+from robot.result.visitor import ResultVisitor
class _Handler(object):
@@ -81,6 +82,24 @@
'errors': self._data_from_children[2],
'baseMillis': self._context.basemillis,
'strings': self._context.dump_texts()}
+
+
+class SuiteStatVisitor(ResultVisitor):
+
+ def __init__(self, collection):
+ self.collection = collection
+
+ def visit_stat(self, stats):
+ stat = self._create_stat(stats)
+ stat['id'] = stats.attrs['idx']
+ stat['name'] = stats.attrs['name']
+ self.collection += [stat]
+
+ def _create_stat(self, stat_elem):
+ return {'pass':stat_elem.passed,
+ 'fail':stat_elem.failed,
+ 'label':stat_elem.name}
+
class StatisticsHandler(object):
@@ -97,18 +116,8 @@
return [self._create_stat(tag) for tag in tags.stats.values()]
def _parse_suite(self, suite):
- class SuiteStatVisitor(object):
- def __init__(self, collection):
- self.collection = collection
- start_suite_stats = end_suite_stats = lambda *args:0
- def suite_stat(s, stats):
- stat = self._create_stat(stats)
- stat['id'] = stats.id
- stat['name'] = stats.name
- stat['label'] = stats.longname
- s.collection += [stat]
stats = []
- suite.serialize(SuiteStatVisitor(stats))
+ suite.visit(SuiteStatVisitor(stats))
return stats
def _create_stat(self, stat_elem):
=======================================
--- /src/robot/result/serializer.py Sat Nov 5 02:54:53 2011
+++ /src/robot/result/serializer.py Mon Nov 14 03:46:38 2011
@@ -35,3 +35,14 @@
def end_result(self, result):
self.close()
+
+ start_total_statistics = XmlLogger.start_total_stats
+ start_tag_statistics = XmlLogger.start_tag_stats
+ start_suite_statistics = XmlLogger.start_suite_stats
+ end_total_statistics = XmlLogger.end_total_stats
+ end_tag_statistics = XmlLogger.end_tag_stats
+ end_suite_statistics = XmlLogger.end_suite_stats
+
+ def visit_stat(self, stat):
+ self._writer.element('stat', stat.name, stat.attrs)
+
=======================================
--- /src/robot/result/visitor.py Wed Nov 9 09:48:30 2011
+++ /src/robot/result/visitor.py Mon Nov 14 03:46:38 2011
@@ -18,11 +18,11 @@
class ResultVisitor(SuiteVisitor):
def visit_result(self, result):
- self.start_result(result)
- self.visit_suite(result.suite)
- self.visit_statistics(result.statistics)
- self.visit_errors(result.errors)
- self.end_result(result)
+ if self.start_result(result) is not False:
+ result.suite.visit(self)
+ result.statistics.visit(self)
+ result.errors.visit(self)
+ self.end_result(result)
def start_result(self, result):
pass
@@ -31,50 +31,68 @@
pass
def visit_statistics(self, stats):
- # TODO: Fix once statistics are rewritten
- self.start_statistics(stats)
- stats.total.serialize(self)
- stats.tags.serialize(self)
- stats.suite.serialize(self)
- self.end_statistics(stats)
+ if self.start_statistics(stats) is not False:
+ stats.total.visit(self)
+ stats.tags.visit(self)
+ stats.suite.visit(self)
+ self.end_statistics(stats)
def start_statistics(self, stats):
pass
- def start_total_stats(self, total_stats):
+ def end_statistics(self, stats):
pass
- def total_stat(self, total_stat):
- pass
-
- def end_total_stats(self, total_stats):
+ def visit_total_statistics(self, stats):
+ if self.start_total_statistics(stats) is not False:
+ for stat in stats:
+ stat.visit(self)
+ self.end_total_statistics(stats)
+
+ def start_total_statistics(self, stats):
pass
- def start_tag_stats(self, tag_stats):
+ def end_total_statistics(self, stats):
pass
- def tag_stat(self, tag_stat):
+ def visit_tag_statistics(self, stats):
+ if self.start_tag_statistics(stats) is not False:
+ for stat in stats:
+ stat.visit(self)
+ self.end_tag_statistics(stats)
+
+ def start_tag_statistics(self, stats):
pass
- def end_tag_stats(self, tag_stats):
+ def end_tag_statistics(self, stats):
pass
- def start_suite_stats(self, suite_stats):
+ def visit_suite_statistics(self, stats):
+ if self.start_suite_statistics(stats) is not False:
+ for stat in stats:
+ stat.visit(self)
+ self.end_suite_statistics(stats)
+
+ def start_suite_statistics(self, stats):
pass
- def suite_stat(self, suite_stat):
+ def end_suite_statistics(self, suite_stats):
pass
- def end_suite_stats(self, suite_stats):
+ def visit_stat(self, stat):
+ if self.start_stat(stat) is not False:
+ self.end_stat(stat)
+
+ def start_stat(self, stat):
pass
- def end_statistics(self, stats):
+ def end_stat(self, stat):
pass
def visit_errors(self, errors):
self.start_errors(errors)
- for msg in errors.messages: # TODO: should errors itself be
iterable?
- self.visit_message(msg)
+ for msg in errors:
+ msg.visit(self)
self.end_errors(errors)
def start_errors(self, errors):
=======================================
--- /utest/model/test_statistics.py Fri Nov 11 04:03:06 2011
+++ /utest/model/test_statistics.py Mon Nov 14 03:46:38 2011
@@ -76,16 +76,16 @@
verify_suite(suite, 'Root Suite', 's1', 2, 2, 4, 3)
assert_equals(len(suite.suites), 2)
s1, s2 = suite.suites
- verify_suite(s1, 'First Sub Suite', 's1-s1', 2, 1, 4, 2)
- verify_suite(s2, 'Second Sub Suite', 's1-s2', 0, 1, 0, 1)
+ verify_suite(s1, 'Root Suite.First Sub Suite', 's1-s1', 2, 1, 4, 2)
+ verify_suite(s2, 'Root Suite.Second Sub Suite', 's1-s2', 0, 1, 0,
1)
assert_equals(len(s1.suites), 3)
s11, s12, s13 = s1.suites
- verify_suite(s11, 'Sub Suite 1_1', 's1-s1-s1', 0, 0, 1, 1)
- verify_suite(s12, 'Sub Suite 1_2', 's1-s1-s2', 1, 1, 2, 1)
- verify_suite(s13, 'Sub Suite 1_3', 's1-s1-s3', 1, 0, 1, 0)
+ verify_suite(s11, 'Root Suite.First Sub Suite.Sub Suite
1_1', 's1-s1-s1', 0, 0, 1, 1)
+ verify_suite(s12, 'Root Suite.First Sub Suite.Sub Suite
1_2', 's1-s1-s2', 1, 1, 2, 1)
+ verify_suite(s13, 'Root Suite.First Sub Suite.Sub Suite
1_3', 's1-s1-s3', 1, 0, 1, 0)
assert_equals(len(s2.suites), 1)
s21 = s2.suites[0]
- verify_suite(s21, 'Sub Suite 2_1', 's1-s2-s1', 0, 1, 0, 1)
+ verify_suite(s21, 'Root Suite.Second Sub Suite.Sub Suite
2_1', 's1-s2-s1', 0, 1, 0, 1)
def test_tags(self):
tags = self.statistics.tags
@@ -99,8 +99,17 @@
verify_stat(tags.stats['t3'], 't3', 0, 2, False, False)
-class TestStatisticsVisitation(unittest.TestCase):
- pass
+class TestSuiteStatLevel(unittest.TestCase):
+
+ def test_stat_level(self):
+ suite = Statistics(generate_default_suite(),
suite_stat_level=2).suite
+ verify_suite(suite, 'Root Suite', 's1', 2, 2, 4, 3)
+ assert_equals(len(suite.suites), 2)
+ s1, s2 = suite.suites
+ verify_suite(s1, 'Root Suite.First Sub Suite', 's1-s1', 2, 1, 4, 2)
+ verify_suite(s2, 'Root Suite.Second Sub Suite', 's1-s2', 0, 1, 0,
1)
+ assert_equals(len(s1.suites), 0)
+ assert_equals(len(s2.suites), 0)
_incl_excl_data = [
@@ -255,7 +264,7 @@
def test_through_suite(self):
suite = generate_default_suite()
suite.set_criticality(critical_tags=['smoke'])
- statistics = Statistics(suite, ['t*','smoke'], ['t3'],
+ statistics = Statistics(suite, 1, ['t*','smoke'], ['t3'],
[('t1 & t2', ''), ('t? & smoke', ''),
('t1 NOT t2', ''), ('none & t1', 'a
title')])
stats = sorted(statistics.tags.stats.values())
=======================================
--- /utest/reporting/test_reporting.py Thu Nov 3 02:15:50 2011
+++ /utest/reporting/test_reporting.py Mon Nov 14 03:46:38 2011
@@ -56,7 +56,7 @@
'LogTitle': None,
'ReportTitle': None,
'ReportBackground': ('green', 'pink', 'red'),
- 'SuiteStatLevel': None,
+ 'SuiteStatLevel': -1,
'SplitLog': False,
'TagStatInclude': None,
'TagStatExclude': None,
==============================================================================
Revision: 4606749b00d5
Author: Janne Härkönen <[email protected]>
Date: Mon Nov 14 03:47:59 2011
Log: Automated merge with https://code.google.com/p/robotframework/
http://code.google.com/p/robotframework/source/detail?r=4606749b00d5