From 09a69c5bc1ef7daafb2b167c43092bf94dc0dee6 Mon Sep 17 00:00:00 2001 From: Robert Collins Date: Wed, 2 May 2012 23:04:11 +1200 Subject: Restore forwarding of all time calls through TestResultFilter. --- python/subunit/test_results.py | 5 +---- python/subunit/tests/test_subunit_filter.py | 28 +++++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 5 deletions(-) (limited to 'python') diff --git a/python/subunit/test_results.py b/python/subunit/test_results.py index bb67df0..1b14c5f 100644 --- a/python/subunit/test_results.py +++ b/python/subunit/test_results.py @@ -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."): diff --git a/python/subunit/tests/test_subunit_filter.py b/python/subunit/tests/test_subunit_filter.py index 664fcb3..d716578 100644 --- a/python/subunit/tests/test_subunit_filter.py +++ b/python/subunit/tests/test_subunit_filter.py @@ -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", -- cgit v1.2.1