Gary Poster has proposed merging lp:~yellow/subunit/real-time into lp:subunit.

Requested reviews:
  Subunit Developers (subunit)
Related bugs:
  Bug #988481 in Testrepository: "Testr tests generate an AttributeError when 
run with latest testtools"
  https://bugs.launchpad.net/testrepository/+bug/988481

For more details, see:
https://code.launchpad.net/~yellow/subunit/real-time/+merge/103701

This change makes the TestResultFilter send all time calls through directly.

It was part of one approach to make the testrepository tests pass for bug 
988481 (see also lp:~yellow/testrepository/bug988481).

testrepository had a class (also called TestResultFilter) that tried to have 
this same approximate behavior--that is, sending all time calls through.  To 
implement, it subclassed subunit's TestResultFilter and then reached into the 
_buffered_calls while in the stopTest method to try and find the time calls.  
Because of use of the decorator pattern, this was fragile.

This change in subunit means that testrepository can use subunit's 
TestResultFilter directly, thereby getting rid of the fragility associated with 
the combination of subclassing, decorating, and accessing a protected attribute.

It also has the possibly irrelevant advantage over the existing implementation 
that, when filtering live streams, the time calls come through also "live," at 
the expected time (assuming processing time is 0).

Tests pass, with the minimal test change describing the new behavior of the 
TestResultFilter itself.

This is work done by Benji York and Brad Crittenden; I'm just helping out with 
the MP.
-- 
https://code.launchpad.net/~yellow/subunit/real-time/+merge/103701
Your team Launchpad Yellow Squad is subscribed to branch 
lp:~yellow/subunit/real-time.
=== modified file 'python/subunit/test_results.py'
--- python/subunit/test_results.py	2012-04-20 11:32:41 +0000
+++ python/subunit/test_results.py	2012-04-26 14:17:22 +0000
@@ -439,10 +439,7 @@
         self._buffered_calls = []
 
     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."):

=== modified file 'python/subunit/tests/test_subunit_filter.py'
--- python/subunit/tests/test_subunit_filter.py	2011-05-09 21:00:42 +0000
+++ python/subunit/tests/test_subunit_filter.py	2012-04-26 14:17:22 +0000
@@ -179,10 +179,11 @@
         result_filter = TestResultFilter(result)
         self.run_tests(result_filter, subunit_stream)
         foo = subunit.RemotedTestCase('foo')
-        self.assertEquals(
+        self.maxDiff = None
+        self.assertSequenceEqual(
             [('time', date_a),
+             ('time', date_b),
              ('startTest', foo),
-             ('time', date_b),
              ('addError', foo, {}),
              ('stopTest', foo),
              ('time', date_c)], result._events)

-- 
Mailing list: https://launchpad.net/~yellow
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~yellow
More help   : https://help.launchpad.net/ListHelp

Reply via email to