Merge updates from tag-collapsing-rigor.
authorJonathan Lange <jml@mumak.net>
Fri, 20 Apr 2012 11:34:31 +0000 (12:34 +0100)
committerJonathan Lange <jml@mumak.net>
Fri, 20 Apr 2012 11:34:31 +0000 (12:34 +0100)
python/subunit/test_results.py
python/subunit/tests/test_test_results.py

index 465b266491635f7625722efc579703e0820ddb4a..fea3b0780be3c9e1944453f30959c63cdd762983 100644 (file)
@@ -248,6 +248,8 @@ class TagCollapsingDecorator(HookedTestResultDecorator):
             self.decorated.tags(new_tags, gone_tags)
         if self._current_test_tags:
             self._current_test_tags = set(), set()
+        else:
+            self._global_tags = set(), set()
 
     def tags(self, new_tags, gone_tags):
         """Handle tag instructions.
index 09b4c2f9cdfc3ed3a367d13826256868236b255a..3c4f68644ead5d6ccde6574b0e15f5af8358c06a 100644 (file)
@@ -212,6 +212,25 @@ class TestTagCollapsingDecorator(TestCase):
              ('startTest', self),
              ], result._events)
 
+    def test_tags_collapsed_outside_of_tests_are_flushed(self):
+        result = ExtendedTestResult()
+        tag_collapser = subunit.test_results.TagCollapsingDecorator(result)
+        tag_collapser.startTestRun()
+        tag_collapser.tags(set(['a']), set())
+        tag_collapser.tags(set(['b']), set())
+        tag_collapser.startTest(self)
+        tag_collapser.addSuccess(self)
+        tag_collapser.stopTest(self)
+        tag_collapser.stopTestRun()
+        self.assertEquals(
+            [('startTestRun',),
+             ('tags', set(['a', 'b']), set([])),
+             ('startTest', self),
+             ('addSuccess', self),
+             ('stopTest', self),
+             ('stopTestRun',),
+             ], result._events)
+
     def test_tags_forwarded_after_tests(self):
         test = subunit.RemotedTestCase('foo')
         result = ExtendedTestResult()