5 new revisions:

Revision: 983674bfb494
Author:   Pekka Klärck
Date:     Fri Nov 18 13:36:14 2011
Log: TagStatistics don't really need __len__. No other stats have it either...
http://code.google.com/p/robotframework/source/detail?r=983674bfb494

Revision: cbd3027ec96e
Author:   Pekka Klärck
Date:     Fri Nov 18 13:37:31 2011
Log:      Build also TotalStatistics using separate builder.
http://code.google.com/p/robotframework/source/detail?r=cbd3027ec96e

Revision: 649973899d76
Author:   Pekka Klärck
Date:     Fri Nov 18 13:46:12 2011
Log: 1) Make TotalStatisticsBuilder able to build TotalStatistics also base...
http://code.google.com/p/robotframework/source/detail?r=649973899d76

Revision: 7e7913f9c139
Author:   Pekka Klärck
Date:     Fri Nov 18 14:26:09 2011
Log: SuiteStatistics: Collect only information about all tests because crit...
http://code.google.com/p/robotframework/source/detail?r=7e7913f9c139

Revision: 6cf26bbf09f9
Author:   Pekka Klärck
Date:     Fri Nov 18 14:26:19 2011
Log:      Automated merge with https://code.google.com/p/robotframework/
http://code.google.com/p/robotframework/source/detail?r=6cf26bbf09f9

==============================================================================
Revision: 983674bfb494
Author:   Pekka Klärck
Date:     Fri Nov 18 13:36:14 2011
Log: TagStatistics don't really need __len__. No other stats have it either.
http://code.google.com/p/robotframework/source/detail?r=983674bfb494

Modified:
 /src/robot/model/tagstatistics.py
 /utest/model/test_statistics.py
 /utest/model/test_tagstatistics.py

=======================================
--- /src/robot/model/tagstatistics.py   Thu Nov 17 13:48:07 2011
+++ /src/robot/model/tagstatistics.py   Fri Nov 18 13:36:14 2011
@@ -31,9 +31,6 @@
     def __iter__(self):
         return iter(sorted(self.tags.values() + self.combined))

-    def __len__(self):
-        return len(self.tags) + len(self.combined)
-

 class TagStatisticsBuilder(object):

=======================================
--- /utest/model/test_statistics.py     Thu Nov 17 14:33:17 2011
+++ /utest/model/test_statistics.py     Fri Nov 18 13:36:14 2011
@@ -84,7 +84,6 @@
     def test_tags(self):
         # Tag stats are tested more thoroughly in their own suite.
         tags = self.statistics.tags
-        assert_equals(len(tags), 5)
         verify_stat(tags.tags['smoke'], 'smoke', 2, 2, True, False)
         verify_stat(tags.tags['t1'], 't1', 3, 2, False, False)
         verify_stat(tags.tags['t2'], 't2', 2, 1, False, False)
=======================================
--- /utest/model/test_tagstatistics.py  Thu Nov 17 14:33:17 2011
+++ /utest/model/test_tagstatistics.py  Fri Nov 18 13:36:14 2011
@@ -50,21 +50,21 @@
             builder.add_test(TestCase(status='PASS', tags=tags))
             assert_equals([s.name for s in builder.stats], exp),

-    def test_len(self):
+    def test_iter(self):
         builder = TagStatisticsBuilder(Criticality())
-        assert_equals(len(builder.stats), 0)
+        assert_equals(list(builder.stats), [])
         builder.add_test(TestCase())
-        assert_equals(len(builder.stats), 0)
+        assert_equals(list(builder.stats), [])
         builder.add_test(TestCase(tags=['a']))
-        assert_equals(len(builder.stats), 1)
+        assert_equals(len(list(builder.stats)), 1)
         builder.add_test(TestCase(tags=['A', 'B']))
-        assert_equals(len(builder.stats), 2)
-
-    def test_len_with_combine(self):
+        assert_equals(len(list(builder.stats)), 2)
+
+    def test_iter_with_combine(self):
builder = TagStatisticsBuilder(Criticality(), combined=[('x*', 'title')])
-        assert_equals(len(builder.stats), 1)
+        assert_equals(len(list(builder.stats)), 1)
         builder.add_test(TestCase(tags=['xxx', 'yyy']))
-        assert_equals(len(builder.stats), 3)
+        assert_equals(len(list(builder.stats)), 3)

     def test_combine_with_name(self):
         for comb_tags, expected_name in [
@@ -76,7 +76,7 @@
                 ([('4NOT5', 'Some new name')], 'Some new name')
                ]:
builder = TagStatisticsBuilder(Criticality(), combined=comb_tags)
-            assert_equals(bool(builder.stats), expected_name != '')
+            assert_equals(bool(list(builder.stats)), expected_name != '')
             if expected_name:
assert_equals([s.name for s in builder.stats], [expected_name])


==============================================================================
Revision: cbd3027ec96e
Author:   Pekka Klärck
Date:     Fri Nov 18 13:37:31 2011
Log:      Build also TotalStatistics using separate builder.
http://code.google.com/p/robotframework/source/detail?r=cbd3027ec96e

Modified:
 /src/robot/model/statistics.py
 /src/robot/model/stats.py
 /src/robot/model/totalstatistics.py

=======================================
--- /src/robot/model/statistics.py      Thu Nov 17 13:39:51 2011
+++ /src/robot/model/statistics.py      Fri Nov 18 13:37:31 2011
@@ -12,9 +12,9 @@
 #  See the License for the specific language governing permissions and
 #  limitations under the License.

-from .tagstatistics import TagStatisticsBuilder
+from .totalstatistics import TotalStatisticsBuilder
 from .suitestatistics import SuiteStatisticsBuilder
-from .totalstatistics import TotalStatistics
+from .tagstatistics import TagStatisticsBuilder
 from .visitor import SuiteVisitor


@@ -23,14 +23,15 @@
     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):
+        total_builder = TotalStatisticsBuilder()
         suite_builder = SuiteStatisticsBuilder(suite_stat_level)
tag_builder = TagStatisticsBuilder(suite.criticality, tag_stat_include, tag_stat_exclude, tag_stat_combine,
                                            tag_doc, tag_stat_link)
-        suite.visit(StatisticsBuilder(suite_builder, tag_builder))
+ suite.visit(StatisticsBuilder(total_builder, suite_builder, tag_builder))
+        self.total = total_builder.stats
         self.suite = suite_builder.root
         self.tags = tag_builder.stats
-        self.total = TotalStatistics(self.suite)

     def visit(self, visitor):
         visitor.visit_statistics(self)
@@ -38,7 +39,8 @@

 class StatisticsBuilder(SuiteVisitor):

-    def __init__(self, suite_builder, tag_builder):
+    def __init__(self, total_builder, suite_builder, tag_builder):
+        self._total_builder = total_builder
         self._suite_builder = suite_builder
         self._tag_builder = tag_builder

@@ -49,6 +51,7 @@
         self._suite_builder.end_suite()

     def visit_test(self, test):
+        self._total_builder.add_test(test)
         self._suite_builder.add_test(test)
         self._tag_builder.add_test(test)

=======================================
--- /src/robot/model/stats.py   Thu Nov 17 12:53:04 2011
+++ /src/robot/model/stats.py   Fri Nov 18 13:37:31 2011
@@ -55,6 +55,10 @@
         visitor.visit_stat(self)


+class TotalStat(Stat):
+    type = 'total'
+
+
 class SuiteStat(Stat):
     type = 'suite'

@@ -111,12 +115,3 @@

     def match(self, tags):
         return self._matcher.match(tags)
-
-
-class TotalStat(Stat):
-    type = 'total'
-
-    def __init__(self, name, suite_stat):
-        Stat.__init__(self, name)
-        self.passed = suite_stat.passed
-        self.failed = suite_stat.failed
=======================================
--- /src/robot/model/totalstatistics.py Mon Nov 14 04:41:32 2011
+++ /src/robot/model/totalstatistics.py Fri Nov 18 13:37:31 2011
@@ -17,12 +17,23 @@

 class TotalStatistics(object):

-    def __init__(self, suite):
-        self.critical = TotalStat('Critical Tests', suite.critical)
-        self.all = TotalStat('All Tests', suite.all)
+    def __init__(self):
+        self.critical = TotalStat('Critical Tests')
+        self.all = TotalStat('All Tests')

     def visit(self, visitor):
         visitor.visit_total_statistics(self)

     def __iter__(self):
         return iter([self.critical, self.all])
+
+
+class TotalStatisticsBuilder(object):
+
+    def __init__(self):
+        self.stats = TotalStatistics()
+
+    def add_test(self, test):
+        self.stats.all.add_test(test)
+        if test.critical == 'yes':
+            self.stats.critical.add_test(test)

==============================================================================
Revision: 649973899d76
Author:   Pekka Klärck
Date:     Fri Nov 18 13:46:12 2011
Log: 1) Make TotalStatisticsBuilder able to build TotalStatistics also based on given suite. 2) Use it instead of Statistics when calculating statistics for TestSuite.
http://code.google.com/p/robotframework/source/detail?r=649973899d76

Modified:
 /src/robot/model/__init__.py
 /src/robot/model/suitestatistics.py
 /src/robot/model/totalstatistics.py
 /src/robot/result/testsuite.py

=======================================
--- /src/robot/model/__init__.py        Mon Nov 14 09:03:47 2011
+++ /src/robot/model/__init__.py        Fri Nov 18 13:46:12 2011
@@ -20,3 +20,5 @@
 from .criticality import Criticality
 from .namepatterns import SuiteNamePatterns, TestNamePatterns
 from .visitor import SuiteVisitor, SkipAllVisitor
+from .totalstatistics import TotalStatisticsBuilder
+from .statistics import StatisticsBuilder
=======================================
--- /src/robot/model/suitestatistics.py Thu Nov 17 13:48:07 2011
+++ /src/robot/model/suitestatistics.py Fri Nov 18 13:46:12 2011
@@ -12,7 +12,7 @@
 #  See the License for the specific language governing permissions and
 #  limitations under the License.

-from robot.model.stats import SuiteStat
+from .stats import SuiteStat


 class SuiteStatistics(object):
=======================================
--- /src/robot/model/totalstatistics.py Fri Nov 18 13:37:31 2011
+++ /src/robot/model/totalstatistics.py Fri Nov 18 13:46:12 2011
@@ -12,7 +12,9 @@
 #  See the License for the specific language governing permissions and
 #  limitations under the License.

-from robot.model.stats import TotalStat
+from .stats import TotalStat
+from .visitor import SuiteVisitor
+


 class TotalStatistics(object):
@@ -28,12 +30,20 @@
         return iter([self.critical, self.all])


-class TotalStatisticsBuilder(object):
-
-    def __init__(self):
+class TotalStatisticsBuilder(SuiteVisitor):
+
+    def __init__(self, suite=None):
         self.stats = TotalStatistics()
+        if suite:
+            suite.visit(self)

     def add_test(self, test):
         self.stats.all.add_test(test)
         if test.critical == 'yes':
             self.stats.critical.add_test(test)
+
+    def visit_test(self, test):
+        self.add_test(test)
+
+    def visit_keyword(self, kw):
+        pass
=======================================
--- /src/robot/result/testsuite.py      Fri Nov 11 01:45:22 2011
+++ /src/robot/result/testsuite.py      Fri Nov 18 13:46:12 2011
@@ -12,7 +12,7 @@
 #  See the License for the specific language governing permissions and
 #  limitations under the License.

-from robot.model.statistics import Statistics
+from robot.model import TotalStatisticsBuilder
 from robot import model, utils

 from messagefilter import MessageFilter
@@ -36,6 +36,10 @@
     def status(self):
         return 'PASS' if not self.critical_stats.failed else 'FAIL'

+    @property
+    def statistics(self):
+        return TotalStatisticsBuilder(self).stats
+
     @property
     def stat_message(self):
         return self._stat_message()
@@ -59,13 +63,15 @@
         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 Statistics(self).suite.critical
+        return self.statistics.critical

     @property
     def all_stats(self):
-        return Statistics(self).suite.all
+        return self.statistics.all

     @property
     def elapsedtime(self):

==============================================================================
Revision: 7e7913f9c139
Author:   Pekka Klärck
Date:     Fri Nov 18 14:26:09 2011
Log: SuiteStatistics: Collect only information about all tests because critical info isn't needed.
http://code.google.com/p/robotframework/source/detail?r=7e7913f9c139

Modified:
 /src/robot/model/statistics.py
 /src/robot/model/suitestatistics.py
 /utest/model/test_statistics.py

=======================================
--- /src/robot/model/statistics.py      Fri Nov 18 13:37:31 2011
+++ /src/robot/model/statistics.py      Fri Nov 18 14:26:09 2011
@@ -30,7 +30,7 @@
                                            tag_doc, tag_stat_link)
suite.visit(StatisticsBuilder(total_builder, suite_builder, tag_builder))
         self.total = total_builder.stats
-        self.suite = suite_builder.root
+        self.suite = suite_builder.stats
         self.tags = tag_builder.stats

     def visit(self, visitor):
=======================================
--- /src/robot/model/suitestatistics.py Fri Nov 18 13:46:12 2011
+++ /src/robot/model/suitestatistics.py Fri Nov 18 14:26:09 2011
@@ -18,28 +18,16 @@
 class SuiteStatistics(object):

     def __init__(self, suite):
-        self.all = SuiteStat(suite)
-        self.critical = SuiteStat(suite)
+        self.stat = SuiteStat(suite)
         self.suites = []

-    def add_test(self, test):
-        self.all.add_test(test)
-        if test.critical == 'yes':
-            self.critical.add_test(test)
-
-    def add_child_stats(self, stats, add_to_suites=True):
-        self.all.add_stat(stats.all)
-        self.critical.add_stat(stats.critical)
-        if add_to_suites:
-            self.suites.append(stats)
-
     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 self.stat
+        for child in self.suites:
+            for stat in child:
                 yield stat


@@ -48,7 +36,7 @@
     def __init__(self, suite_stat_level):
         self._suite_stat_level = suite_stat_level
         self._stats_stack = []
-        self.root = None
+        self.stats = None

     @property
     def current(self):
@@ -56,16 +44,18 @@

     def start_suite(self, suite):
         self._stats_stack.append(SuiteStatistics(suite))
-        if self.root is None:
-            self.root = self.current
+        if self.stats is None:
+            self.stats = self.current

     def add_test(self, test):
-        self.current.add_test(test)
+        self.current.stat.add_test(test)

     def end_suite(self):
         stats = self._stats_stack.pop()
         if self.current:
-            self.current.add_child_stats(stats, self._is_child_included())
+            self.current.stat.add_stat(stats.stat)
+            if self._is_child_included():
+                self.current.suites.append(stats)

     def _is_child_included(self):
         return self._include_all_levels() or self._below_threshold()
=======================================
--- /utest/model/test_statistics.py     Fri Nov 18 13:36:14 2011
+++ /utest/model/test_statistics.py     Fri Nov 18 14:26:09 2011
@@ -16,11 +16,8 @@
     if id:
         assert_equals(stat.id, id)

-def verify_suite(suite, name, id, crit_pass, crit_fail, all_pass=None, all_fail=None):
-    verify_stat(suite.critical, name, crit_pass, crit_fail, id=id)
-    if all_pass is None:
-        all_pass, all_fail = crit_pass, crit_fail
-    verify_stat(suite.all, name, all_pass, all_fail, id=id)
+def verify_suite(suite, name, id, passed, failed):
+    verify_stat(suite.stat, name, passed, failed, id=id)

 def generate_suite():
     suite = TestSuite(name='Root Suite')
@@ -73,11 +70,10 @@

     def test_suite(self):
         suite = self.statistics.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)
+        verify_suite(suite, 'Root Suite', 's1', 4, 3)
+        [s1, s2] = suite.suites
+        verify_suite(s1, 'Root Suite.First Sub Suite', 's1-s1', 4, 2)
+        verify_suite(s2, 'Root Suite.Second Sub Suite', 's1-s2', 0, 1)
         assert_equals(len(s1.suites), 0)
         assert_equals(len(s2.suites), 0)

@@ -95,23 +91,20 @@

     def test_all_levels(self):
         suite = Statistics(generate_suite()).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), 3)
-        s11, s12, s13 = s1.suites
- 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, 'Root Suite.Second Sub Suite.Sub Suite 2_1', 's1-s2-s1', 0, 1, 0, 1)
+        verify_suite(suite, 'Root Suite', 's1', 4, 3)
+        [s1, s2] = suite.suites
+        verify_suite(s1, 'Root Suite.First Sub Suite', 's1-s1', 4, 2)
+        verify_suite(s2, 'Root Suite.Second Sub Suite', 's1-s2', 0, 1)
+        [s11, s12, s13] = s1.suites
+ verify_suite(s11, 'Root Suite.First Sub Suite.Sub Suite 1_1', 's1-s1-s1', 1, 1) + verify_suite(s12, 'Root Suite.First Sub Suite.Sub Suite 1_2', 's1-s1-s2', 2, 1) + verify_suite(s13, 'Root Suite.First Sub Suite.Sub Suite 1_3', 's1-s1-s3', 1, 0)
+        [s21] = s2.suites
+ verify_suite(s21, 'Root Suite.Second Sub Suite.Sub Suite 2_1', 's1-s2-s1', 0, 1)

     def test_only_root_level(self):
         suite = Statistics(generate_suite(), suite_stat_level=1).suite
-        verify_suite(suite, 'Root Suite', 's1', 2, 2, 4, 3)
+        verify_suite(suite, 'Root Suite', 's1', 4, 3)
         assert_equals(len(suite.suites), 0)

     def test_deeper_level(self):
@@ -139,6 +132,20 @@
         verify_suite(s122, '1.2.2', 's1-s2-s2', 2, 2)
         assert_equals(len(s111.suites), 0)

+    def test_iter_only_one_level(self):
+ [stat] = list(Statistics(generate_suite(), suite_stat_level=1).suite)
+        verify_stat(stat, 'Root Suite', 4, 3, id='s1')
+
+    def test_iter_also_sub_suites(self):
+        stats = list(Statistics(generate_suite()).suite)
+        verify_stat(stats[0], 'Root Suite', 4, 3, id='s1')
+ verify_stat(stats[1], 'Root Suite.First Sub Suite', 4, 2, id='s1-s1') + verify_stat(stats[2], 'Root Suite.First Sub Suite.Sub Suite 1_1', 1, 1, id='s1-s1-s1') + verify_stat(stats[3], 'Root Suite.First Sub Suite.Sub Suite 1_2', 2, 1, id='s1-s1-s2') + verify_stat(stats[4], 'Root Suite.First Sub Suite.Sub Suite 1_3', 1, 0, id='s1-s1-s3') + verify_stat(stats[5], 'Root Suite.Second Sub Suite', 0, 1, id='s1-s2') + verify_stat(stats[6], 'Root Suite.Second Sub Suite.Sub Suite 2_1', 0, 1, id='s1-s2-s1')
+

 if __name__ == "__main__":
     unittest.main()

==============================================================================
Revision: 6cf26bbf09f9
Author:   Pekka Klärck
Date:     Fri Nov 18 14:26:19 2011
Log:      Automated merge with https://code.google.com/p/robotframework/
http://code.google.com/p/robotframework/source/detail?r=6cf26bbf09f9


Reply via email to