Flush global tags too.
authorJonathan Lange <jml@mumak.net>
Fri, 20 Apr 2012 11:32:41 +0000 (12:32 +0100)
committerJonathan Lange <jml@mumak.net>
Fri, 20 Apr 2012 11:32:41 +0000 (12:32 +0100)
python/subunit/test_results.py
python/subunit/tests/test_test_results.py

index 4a55cf8e4829b8d328bc0a9e69e9202991f20930..8db40e15a8d31536794b81879c7374abb1f4f648 100644 (file)
@@ -244,6 +244,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()