2 new revisions:

Revision: d98ce7729d60
Author:   Pekka Klärck
Date:     Tue Nov 29 01:53:28 2011
Log: Removed parsingcontext.Stats because it wasn't needed anymore now that...
http://code.google.com/p/robotframework/source/detail?r=d98ce7729d60

Revision: 76af5b98c657
Author:   Pekka Klärck
Date:     Tue Nov 29 01:53:41 2011
Log:      Automated merge with https://code.google.com/p/robotframework/
http://code.google.com/p/robotframework/source/detail?r=76af5b98c657

==============================================================================
Revision: d98ce7729d60
Author:   Pekka Klärck
Date:     Tue Nov 29 01:53:28 2011
Log: Removed parsingcontext.Stats because it wasn't needed anymore now that suite teardown failures are handled earlier.
http://code.google.com/p/robotframework/source/detail?r=d98ce7729d60

Modified:
 /src/robot/reporting/parsingcontext.py
 /src/robot/result/jsondatamodelhandlers.py
 /utest/reporting/test_parsingcontext.py

=======================================
--- /src/robot/reporting/parsingcontext.py      Mon Oct 24 03:12:31 2011
+++ /src/robot/reporting/parsingcontext.py      Tue Nov 29 01:53:28 2011
@@ -25,7 +25,6 @@
         self._current_texts = self._main_text_cache
         self._split_text_caches = []
         self.basemillis = 0
-        self._stats = Stats()
         self._location = Location()
         self._links = {}
         self._split_log = split_log
@@ -64,13 +63,9 @@

     def start_suite(self):
         self._location.start_suite()
-        self._stats = self._stats.new_child()

     def end_suite(self):
         self._location.end_suite()
-        stats = self._stats
-        self._stats = self._stats.parent
-        return stats

     def start_test(self):
         if self._split_log:
@@ -112,75 +107,6 @@
     def link_to(self, key):
         return self._links[tuple(key)]

-    def add_test(self, critical, passed):
-        self._stats.add_test(critical, passed)
-
-    def suite_teardown_failed(self):
-        self._stats.suite_teardown_failed()
-
-
-class Stats(object):
-
-    def __init__(self, parent=None):
-        self.parent = parent
-        self.all = 0
-        self.all_passed = 0
-        self.critical = 0
-        self.critical_passed = 0
-        self._children = []
-
-    def new_child(self):
-        self._children.append(Stats(self))
-        return self._children[-1]
-
-    def add_test(self, critical, passed):
-        self._update_stats(critical, passed)
-        if self.parent:
-            self.parent.add_test(critical, passed)
-
-    def _update_stats(self, critical, passed):
-        self.all += 1
-        if passed:
-            self.all_passed += 1
-        if critical:
-            self.critical += 1
-        if critical and passed:
-            self.critical_passed += 1
-
-    def suite_teardown_failed(self):
-        if self.parent:
- self._child_teardown_failed(self.all_passed, self.critical_passed)
-        self._parent_teardown_failed()
-
-    def _child_teardown_failed(self, all_passed, critical_passed):
-        self.all_passed -= all_passed
-        self.critical_passed -= critical_passed
-        if self.parent:
-            self.parent._child_teardown_failed(all_passed, critical_passed)
-
-    def _parent_teardown_failed(self):
-        self.all_passed = 0
-        self.critical_passed = 0
-        for child in self._children:
-            child._parent_teardown_failed()
-
-    def __iter__(self):
-        return iter([self.all, self.all_passed,
-                     self.critical, self.critical_passed])
-
-    def __len__(self):
-        return 4
-
-    def __eq__(self, other):
-        for i,j in zip(self, other):
-            if i != j:
-                return False
-        return True
-
-    def __ne__(self, other):
-        return not (self == other)
-
-

 class Location(object):

=======================================
--- /src/robot/result/jsondatamodelhandlers.py  Tue Nov 29 01:20:19 2011
+++ /src/robot/result/jsondatamodelhandlers.py  Tue Nov 29 01:53:28 2011
@@ -153,7 +153,6 @@
         return SuiteKeywordHandler(self._context)

     def build(self, suite):
-        stats = self._context.end_suite()
         return [self._id(suite.name),
                 self._id(suite.source),
                 self._id(self._context.get_rel_log_path(suite.source)),
@@ -163,8 +162,7 @@
                 self._suites,
                 self._tests,
                 self._keywords,
-                stats]
-
+                self._stats(suite)]

     def _metadata(self, suite):
         metadata = []
@@ -172,6 +170,11 @@
metadata.extend([self._id(name), self._id(utils.html_format(value))])
         return metadata

+    def _stats(self, suite):
+        stats = suite.statistics  # Access property only once
+        return [stats.all.total, stats.all.failed,
+                stats.critical.total, stats.critical.failed]
+

 class TestHandler(_Handler):

@@ -180,12 +183,10 @@
         self._context.start_test()

     def build(self, test):
-        critical = int(test.critical == 'yes')
-        self._context.add_test(critical, test.status == 'PASS')
         self._keywords = self._context.end_test(self._keywords)
         return [self._id(test.name),
                 self._id(test.timeout),
-                critical,
+                int(test.critical == 'yes'),
                 self._id_html(test.doc),
                 [self._id(tag) for tag in test.tags],
                 self._status(test),
=======================================
--- /utest/reporting/test_parsingcontext.py     Mon Oct 24 03:12:31 2011
+++ /utest/reporting/test_parsingcontext.py     Tue Nov 29 01:53:28 2011
@@ -4,7 +4,7 @@
 import unittest
 from sys import maxint

-from robot.reporting.parsingcontext import Context, TextCache, Stats, Location, TextIndex +from robot.reporting.parsingcontext import Context, TextCache, Location, TextIndex
 from robot.utils.asserts import assert_equals, assert_true


@@ -166,61 +166,6 @@
         assert_equals(str(value), str(target))


-class TestStats(unittest.TestCase):
-
-    def setUp(self):
-        self.s1 = Stats()
-        self.s11 = self.s1.new_child()
-        self.s12 = self.s1.new_child()
-        self.s121 = self.s12.new_child()
-        self.s1211 = self.s121.new_child()
-
-    def _test(self, stats, all, all_passed, crit=None, crit_passed=None):
-        if crit is None:
-            crit, crit_passed = all, all_passed
-        assert_equals(stats.all, all)
-        assert_equals(stats.all_passed, all_passed)
-        assert_equals(stats.critical, crit)
-        assert_equals(stats.critical_passed, crit_passed)
-        assert_equals(list(stats), [all, all_passed, crit, crit_passed])
-
-    def test_add_test(self):
-        self.s1.add_test(critical=True, passed=True)
-        self._test(self.s1, 1, 1)
-        self.s11.add_test(True, False)
-        self._test(self.s1, 2, 1)
-        self._test(self.s11, 1, 0)
-        self.s1211.add_test(False, True)
-        self._test(self.s1, 3, 2, 2, 1)
-        self._test(self.s11, 1, 0)
-        self._test(self.s12, 1, 1, 0, 0)
-        self._test(self.s121, 1, 1, 0, 0)
-        self._test(self.s1211, 1, 1, 0, 0)
-
-    def test_teardown_failed(self):
-        self.s1.add_test(critical=True, passed=True)
-        self.s12.add_test(True, True)
-        self.s121.add_test(True, True)
-        self.s1211.add_test(False, True)
-        self.s121.suite_teardown_failed()
-        self._test(self.s1211, 1, 0, 0, 0)
-        self._test(self.s121, 2, 0, 1, 0)
-        self._test(self.s12, 3, 1, 2, 1)
-        self._test(self.s1, 4, 2, 3, 2)
-
-    def test_stats_through_context(self):
-        context = Context()
-        context.start_suite()
-        context.start_suite()
-        context.add_test(1,1)
-        child_stats = context.end_suite()
-        self.assertEqual(list(child_stats), [1, 1, 1, 1])
-        context.suite_teardown_failed()
-        parent_stats = context.end_suite()
-        self.assertEqual(list(child_stats), [1, 0, 1, 0])
-        self.assertEqual(list(parent_stats), [1, 0, 1, 0])
-
-
 class TestLocation(unittest.TestCase):

     def setUp(self):

==============================================================================
Revision: 76af5b98c657
Author:   Pekka Klärck
Date:     Tue Nov 29 01:53:41 2011
Log:      Automated merge with https://code.google.com/p/robotframework/
http://code.google.com/p/robotframework/source/detail?r=76af5b98c657


Reply via email to