Merge lp:~yellow/subunit/real-time into lp:~subunit/subunit/trunk

Proposed by Gary Poster
Status: Merged
Merged at revision: 164
Proposed branch: lp:~yellow/subunit/real-time
Merge into: lp:~subunit/subunit/trunk
Diff against target: 33 lines (+4/-6)
2 files modified
python/subunit/test_results.py (+1/-4)
python/subunit/tests/test_subunit_filter.py (+3/-2)
To merge this branch: bzr merge lp:~yellow/subunit/real-time
Reviewer Review Type Date Requested Status
Jonathan Lange Approve
Review via email: mp+103701@code.launchpad.net

Description of the change

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.

To post a comment you must log in.
Revision history for this message
Jonathan Lange (jml) wrote :

I'm not 100% sure about this change, but I can't think of any actual use case for which this would be a regression.

review: Approve
Revision history for this message
Jonathan Lange (jml) wrote :

This accidentally found its way into a private email discussion:

jml: If it were parametrized somehow (an option or something) then I'd be 100% happy. Merging as-is anyway.

Gary: Cool, thank you. Benji, tossing this to you in case you want to do anything with it.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'python/subunit/test_results.py'
2--- python/subunit/test_results.py 2012-04-20 11:32:41 +0000
3+++ python/subunit/test_results.py 2012-04-26 14:17:22 +0000
4@@ -439,10 +439,7 @@
5 self._buffered_calls = []
6
7 def time(self, a_time):
8- if self._current_test is not None:
9- self._buffered_calls.append(('time', [a_time], {}))
10- else:
11- return self.decorated.time(a_time)
12+ return self.decorated.time(a_time)
13
14 def id_to_orig_id(self, id):
15 if id.startswith("subunit.RemotedTestCase."):
16
17=== modified file 'python/subunit/tests/test_subunit_filter.py'
18--- python/subunit/tests/test_subunit_filter.py 2011-05-09 21:00:42 +0000
19+++ python/subunit/tests/test_subunit_filter.py 2012-04-26 14:17:22 +0000
20@@ -179,10 +179,11 @@
21 result_filter = TestResultFilter(result)
22 self.run_tests(result_filter, subunit_stream)
23 foo = subunit.RemotedTestCase('foo')
24- self.assertEquals(
25+ self.maxDiff = None
26+ self.assertSequenceEqual(
27 [('time', date_a),
28+ ('time', date_b),
29 ('startTest', foo),
30- ('time', date_b),
31 ('addError', foo, {}),
32 ('stopTest', foo),
33 ('time', date_c)], result._events)

Subscribers

People subscribed via source and target branches