Revision: 31613f3ce0ab
Author:   Pekka Klärck
Date:     Mon Nov 14 16:39:48 2011
Log:      TagStatistics: expose tags and combined attributes
http://code.google.com/p/robotframework/source/detail?r=31613f3ce0ab

Modified:
 /atest/robot/tags/tags_are_not_normalized.txt
 /src/robot/model/tagstatistics.py
 /utest/model/test_statistics.py

=======================================
--- /atest/robot/tags/tags_are_not_normalized.txt       Tue Nov  1 01:13:47 2011
+++ /atest/robot/tags/tags_are_not_normalized.txt       Mon Nov 14 16:39:48 2011
@@ -20,7 +20,7 @@
     Check Test Tags  Normalized Duplicates Are Removed  hello

 Statistics Are Counted In Normalized Manner
-    Should Be Equal  ${STATISTICS.tags.stats['tag'].failed}  ${5}
+    Should Be Equal  ${STATISTICS.tags.tags['tag'].failed}  ${5}

 Including And Excluding Works in Normalized Manner
[Documentation] Including is actually tested using --include when running tests. If all previous tests pass then including works.
@@ -33,5 +33,5 @@
Run Rebot --exclude LOWER --exclude 2spaces --exclude *D?O?T?S* --settag AddedSPACEtag --escape space:SPACE ${OUTFILE}
     Check Test Tags  Sorting Is Normalized  A 0  a1  A2  Added tag
     Check Test Tags  Normalized Duplicates Are Removed  Added tag  hello
-    Should Be Equal  ${STATISTICS.tags.stats['tag'].failed}  ${5}
-
+    Should Be Equal  ${STATISTICS.tags.tags['tag'].failed}  ${5}
+
=======================================
--- /src/robot/model/tagstatistics.py   Mon Nov 14 15:56:32 2011
+++ /src/robot/model/tagstatistics.py   Mon Nov 14 16:39:48 2011
@@ -24,12 +24,12 @@
def __init__(self, criticality, include=None, exclude=None, combine=None,
                  docs=None, links=None):
         # TODO: Check argument names
-        self._tags = utils.NormalizedDict(ignore=['_'])
+        self.tags = utils.NormalizedDict(ignore=['_'])
         self._include = TagPatterns(include)
         self._exclude = TagPatterns(exclude)
         self._info = TagStatInfo(criticality, docs, links)
-        self._combined = [self._info.get_combined_stat(pattern, name)
-                          for pattern, name in combine or []]
+        self.combined = [self._info.get_combined_stat(pattern, name)
+                         for pattern, name in combine or []]

     def add_test(self, test):
         self._add_tags_to_statistics(test)
@@ -38,9 +38,9 @@
     def _add_tags_to_statistics(self, test):
         for tag in test.tags:
             if self._is_included(tag):
-                if tag not in self._tags:
-                    self._tags[tag] = self._info.get_stat(tag)
-                self._tags[tag].add_test(test)
+                if tag not in self.tags:
+                    self.tags[tag] = self._info.get_stat(tag)
+                self.tags[tag].add_test(test)

     def _is_included(self, tag):
         if self._include and not self._include.match(tag):
@@ -48,7 +48,7 @@
         return not self._exclude.match(tag)

     def _add_to_combined_statistics(self, test):
-        for comb in self._combined:
+        for comb in self.combined:
             if comb.match(test.tags):
                 comb.add_test(test)

@@ -56,10 +56,10 @@
         visitor.visit_tag_statistics(self)

     def __iter__(self):
-        return iter(sorted(self._tags.values() + self._combined))
+        return iter(sorted(self.tags.values() + self.combined))

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


 class TagStatInfo(object):
=======================================
--- /utest/model/test_statistics.py     Mon Nov 14 16:11:39 2011
+++ /utest/model/test_statistics.py     Mon Nov 14 16:39:48 2011
@@ -92,10 +92,10 @@
         assert_equals(len(tags), 4)
         names = [t.name for t in tags]
         assert_equals(names, 'smoke t1 t2 t3'.split())
-        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)
-        verify_stat(tags._tags['t3'], 't3', 0, 2, False, False)
+        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)
+        verify_stat(tags.tags['t3'], 't3', 0, 2, False, False)


 class TestSuiteStatLevel(unittest.TestCase):

Reply via email to