Merge lp:~yellow/testrepository/bug988481 into lp:~testrepository/testrepository/trunk

Proposed by Gary Poster
Status: Rejected
Rejected by: Robert Collins
Proposed branch: lp:~yellow/testrepository/bug988481
Merge into: lp:~testrepository/testrepository/trunk
Diff against target: 119 lines (+5/-47)
6 files modified
testrepository/commands/failing.py (+1/-1)
testrepository/commands/last.py (+1/-1)
testrepository/results.py (+0/-39)
testrepository/tests/commands/test_load.py (+0/-1)
testrepository/tests/test_results.py (+2/-4)
testrepository/ui/cli.py (+1/-1)
To merge this branch: bzr merge lp:~yellow/testrepository/bug988481
Reviewer Review Type Date Requested Status
Robert Collins Disapprove
Review via email: mp+103704@code.launchpad.net

Description of the change

This branch depends on lp:~yellow/subunit/real-time and lp:~yellow/subunit/test-count. The following MP text is slightly modified from the MP for the first branch.

testrepository had a class (also called TestResultFilter) that tried to send 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.

The associated change in subunit gives that class the behavior that testrepository wants.

This change in subunit, plus the change in lp:~yellow/subunit/test-count, 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.

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 :

Thanks. I'm very much in favour of removing this subclass, and this patch looks like the right way to do it. I've taken issue with https://code.launchpad.net/~yellow/subunit/test-count/+merge/103717, and I suspect this patch will have to change as a result of required changes there.

Revision history for this message
Robert Collins (lifeless) wrote :

This would drop compatability with the prior release of subunit; we try moderately hard to make each new release compatible with the prior release of the related libraries; that makes migration a lot easier for users. I'll roll a relevant update into my WIP branch.

review: Disapprove

Unmerged revisions

149. By Gary Poster

remove functionality that has been moved into subunit

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'testrepository/commands/failing.py'
2--- testrepository/commands/failing.py 2010-10-01 15:49:32 +0000
3+++ testrepository/commands/failing.py 2012-04-26 14:20:32 +0000
4@@ -19,7 +19,7 @@
5 from testtools import MultiTestResult, TestResult
6
7 from testrepository.commands import Command
8-from testrepository.results import TestResultFilter
9+from subunit.test_results import TestResultFilter
10
11
12 class failing(Command):
13
14=== modified file 'testrepository/commands/last.py'
15--- testrepository/commands/last.py 2011-11-03 20:41:47 +0000
16+++ testrepository/commands/last.py 2012-04-26 14:20:32 +0000
17@@ -15,7 +15,7 @@
18 """Show the last run loaded into a repository."""
19
20 from testrepository.commands import Command
21-from testrepository.results import TestResultFilter
22+from subunit.test_results import TestResultFilter
23
24
25 class last(Command):
26
27=== modified file 'testrepository/results.py'
28--- testrepository/results.py 2011-11-02 20:55:16 +0000
29+++ testrepository/results.py 2012-04-26 14:20:32 +0000
30@@ -1,47 +1,8 @@
31-from subunit import test_results
32-
33 from testtools import TestResult
34
35 from testrepository.utils import timedelta_to_seconds
36
37
38-class TestResultFilter(test_results.TestResultFilter):
39- """Test result filter."""
40-
41- def _get_concrete_result(self):
42- # XXX: This is really crappy. It assumes that the test result we
43- # actually care about is decorated and that we can find our way to the
44- # one we care about. We want to report counts before filtering, so we
45- # should actually use two result objects - one to count and one to
46- # show. Arguably also the testsRun incrementing facility should be in
47- # testtools / subunit
48- concrete = self
49- while True:
50- next = getattr(concrete, 'decorated', None)
51- if next is None:
52- return concrete
53- concrete = next
54-
55- def _filtered(self):
56- super(TestResultFilter, self)._filtered()
57- concrete = self._get_concrete_result()
58- concrete.testsRun += 1
59-
60- def stopTest(self, test):
61- # Filter out 'time' calls, because we want to forward those events
62- # regardless of whether the test is filtered.
63- #
64- # XXX: Should this be pushed into subunit?
65- buffered_calls = []
66- for method, args, kwargs in self._buffered_calls:
67- if method == 'time':
68- self.decorated.time(*args, **kwargs)
69- else:
70- buffered_calls.append((method, args, kwargs))
71- self._buffered_calls = buffered_calls
72- super(TestResultFilter, self).stopTest(test)
73-
74-
75 class SummarizingResult(TestResult):
76
77 def __init__(self):
78
79=== modified file 'testrepository/tests/commands/test_load.py'
80--- testrepository/tests/commands/test_load.py 2012-04-19 13:27:28 +0000
81+++ testrepository/tests/commands/test_load.py 2012-04-26 14:20:32 +0000
82@@ -27,7 +27,6 @@
83 from testrepository.ui.model import UI
84 from testrepository.tests import ResourcedTestCase, Wildcard
85 from testrepository.tests.test_repository import RecordingRepositoryFactory
86-from testrepository.tests.repository.test_file import HomeDirTempDir
87 from testrepository.repository import memory, RepositoryNotFound
88
89
90
91=== modified file 'testrepository/tests/test_results.py'
92--- testrepository/tests/test_results.py 2011-11-02 20:55:16 +0000
93+++ testrepository/tests/test_results.py 2012-04-26 14:20:32 +0000
94@@ -25,10 +25,8 @@
95 ThreadsafeForwardingResult,
96 )
97
98-from testrepository.results import (
99- SummarizingResult,
100- TestResultFilter,
101- )
102+from subunit.test_results import TestResultFilter
103+from testrepository.results import SummarizingResult
104 from testrepository.ui import BaseUITestResult
105 from testrepository.ui.model import UI
106
107
108=== modified file 'testrepository/ui/cli.py'
109--- testrepository/ui/cli.py 2012-04-17 20:05:44 +0000
110+++ testrepository/ui/cli.py 2012-04-26 14:20:32 +0000
111@@ -23,7 +23,7 @@
112 from testtools.compat import unicode_output_stream
113
114 from testrepository import ui
115-from testrepository.results import TestResultFilter
116+from subunit.test_results import TestResultFilter
117
118
119 class CLITestResult(ui.BaseUITestResult):

Subscribers

People subscribed via source and target branches