Restore forwarding of all time calls through TestResultFilter.
authorRobert Collins <robertc@robertcollins.net>
Wed, 2 May 2012 11:04:11 +0000 (23:04 +1200)
committerRobert Collins <robertc@robertcollins.net>
Wed, 2 May 2012 11:04:11 +0000 (23:04 +1200)
python/subunit/test_results.py
python/subunit/tests/test_subunit_filter.py

index bb67df0a3526304d4e4e6d251a73d470fe1d95c9..1b14c5f157fe4d3e137ee536b4f466a7fda132a6 100644 (file)
@@ -420,10 +420,7 @@ class _PredicateFilter(TestResultDecorator, TagsMixin):
             return super(_PredicateFilter, self).tags(new_tags, gone_tags)
 
     def time(self, a_time):
-        if self._current_test is not None:
-            self._buffered_calls.append(('time', [a_time], {}))
-        else:
-            return self.decorated.time(a_time)
+        return self.decorated.time(a_time)
 
     def id_to_orig_id(self, id):
         if id.startswith("subunit.RemotedTestCase."):
index 664fcb38e70ba8baf89e196af87682430472afb3..d716578f426ac4b38572d38d1993e9bc2bcf9d28 100644 (file)
@@ -233,12 +233,38 @@ xfail todo
         self.maxDiff = None
         self.assertSequenceEqual(
             [('time', date_a),
-             ('startTest', foo),
              ('time', date_b),
+             ('startTest', foo),
              ('addError', foo, {}),
              ('stopTest', foo),
              ('time', date_c)], result._events)
 
+    def test_time_passes_through_filtered_tests(self):
+        # Passing a subunit stream through TestResultFilter preserves 'time'
+        # directives even if a specific test is filtered out.
+        date_a = datetime(year=2000, month=1, day=1, tzinfo=iso8601.UTC)
+        date_b = datetime(year=2000, month=1, day=2, tzinfo=iso8601.UTC)
+        date_c = datetime(year=2000, month=1, day=3, tzinfo=iso8601.UTC)
+        subunit_stream = _b('\n'.join([
+            "time: %s",
+            "test: foo",
+            "time: %s",
+            "success: foo",
+            "time: %s",
+            ""]) % (date_a, date_b, date_c))
+        result = ExtendedTestResult()
+        result_filter = TestResultFilter(result)
+        result_filter.startTestRun()
+        self.run_tests(result_filter, subunit_stream)
+        result_filter.stopTestRun()
+        foo = subunit.RemotedTestCase('foo')
+        self.maxDiff = None
+        self.assertSequenceEqual(
+            [('startTestRun',),
+             ('time', date_a),
+             ('time', date_c),
+             ('stopTestRun',),], result._events)
+
     def test_skip_preserved(self):
         subunit_stream = _b('\n'.join([
             "test: foo",