Merge lp:~jml/launchpad/new-zope-testing into lp:launchpad

Proposed by Jonathan Lange on 2010-03-17
Status: Merged
Approved by: Jonathan Lange on 2010-03-19
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~jml/launchpad/new-zope-testing
Merge into: lp:launchpad
Diff against target: 236 lines (+12/-111)
5 files modified
buildout-templates/bin/test.in (+4/-39)
lib/canonical/launchpad/webapp/metazcml.py (+2/-2)
lib/canonical/testing/customresult.py (+2/-65)
utilities/sourcedeps.conf (+0/-1)
versions.cfg (+4/-4)
To merge this branch: bzr merge lp:~jml/launchpad/new-zope-testing
Reviewer Review Type Date Requested Status
Paul Hummer (community) code 2010-03-17 Approve on 2010-03-18
Review via email: mp+21539@code.launchpad.net

Commit message

Upgrade zope.testing to 3.9.2, delete our crufty subunit support

Description of the change

This branch upgrades zope.testing to 3.9.2 and subunit to 0.0.5. The new zope.testing comes with vastly better subunit support than the hacky stuff that's in the Launchpad tree, so I deleted the stuff in the Launchpad tree.

subunit is now managed with buildout using the cmmi recipe. I didn't really know what I was doing here, but it seems to work.

To post a comment you must log in.
Paul Hummer (rockstar) wrote :

Wow, 14 new lines, but 106 removed? Can we have more patches like this? I'm quite happy to have subunit output.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'buildout-templates/bin/test.in'
2--- buildout-templates/bin/test.in 2010-02-24 16:44:39 +0000
3+++ buildout-templates/bin/test.in 2010-04-13 10:36:35 +0000
4@@ -97,6 +97,9 @@
5 'ignore', 'twisted.python.plugin', DeprecationWarning,
6 )
7 warnings.filterwarnings(
8+ 'ignore', 'zope.testing.doctest', DeprecationWarning,
9+ )
10+warnings.filterwarnings(
11 'ignore', 'bzrlib.*was deprecated', DeprecationWarning
12 )
13 # The next one is caused by a lamosity in python-openid. The following change
14@@ -164,14 +167,7 @@
15 os.listdir = listdir
16
17
18-from canonical.testing.customresult import (
19- filter_tests,
20- list_tests,
21- patch_find_tests,
22- patch_zope_testresult,
23- replace_list_of_tests,
24- )
25-from subunit import TestProtocolClient
26+from canonical.testing.customresult import filter_tests, patch_find_tests
27
28
29 if __name__ == '__main__':
30@@ -195,41 +191,10 @@
31 options.parser.add_option(
32 '--load-list', type=str, action='callback', callback=load_list)
33
34- def list_test_option(option, opt, value, parser):
35- patch_find_tests(list_tests)
36- options.parser.add_option(
37- '--list', action='callback', callback=list_test_option)
38-
39- def save_list_test_option(option, opt, value, parser):
40- # Replace zope.testing's list_of_tests() method with our own
41- # that prints test IDs to the file given at the command line.
42- replace_list_of_tests(open(value, 'wb'))
43- # Get zope.testing to produce a listing. This works because
44- # this option parser is actually called twice, once here and
45- # once again within zope.testing.
46- args.append('--list-tests')
47- options.parser.add_option(
48- '--save-list', action='callback',
49- callback=save_list_test_option, type="str")
50-
51- def use_subunit(option, opt, value, parser):
52- patch_zope_testresult(TestProtocolClient(sys.stdout))
53- options.parser.add_option(
54- '--subunit', action='callback', callback=use_subunit)
55-
56 # tests_pattern is a regexp, so the parsed value is hard to compare
57 # with the default value in the loop below.
58 options.parser.defaults['tests_pattern'] = defaults['tests_pattern']
59 local_options = options.get_options(args=args)
60- if os.getenv("SUBUNIT_FORMATTER"):
61- try:
62- from subunit import get_default_formatter
63- except ImportError:
64- # Not a new enough subunit
65- pass
66- else:
67- stream = get_default_formatter()
68- patch_zope_testresult(TestProtocolClient(stream))
69 # Set our default options, if the options aren't specified.
70 for name, value in defaults.items():
71 parsed_option = getattr(local_options, name)
72
73=== modified file 'lib/canonical/launchpad/webapp/metazcml.py'
74--- lib/canonical/launchpad/webapp/metazcml.py 2010-01-09 00:27:05 +0000
75+++ lib/canonical/launchpad/webapp/metazcml.py 2010-04-13 10:36:35 +0000
76@@ -8,11 +8,11 @@
77 import zope.app.form.browser.metadirectives
78 import zope.app.publisher.browser.metadirectives
79 import zope.configuration.config
80-from zope.app.component.metaconfigure import PublicPermission, view
81 from zope.app.file.image import Image
82 from zope.app.pagetemplate.engine import TrustedEngine
83 from zope.component import getUtility
84-from zope.component.zcml import adapter, handler, utility
85+from zope.component.security import PublicPermission
86+from zope.component.zcml import adapter, handler, utility, view
87 from zope.configuration.fields import (
88 GlobalInterface, GlobalObject, Path, PythonIdentifier, Tokens)
89 from zope.interface import Interface, implements
90
91=== modified file 'lib/canonical/testing/customresult.py'
92--- lib/canonical/testing/customresult.py 2009-12-07 10:24:26 +0000
93+++ lib/canonical/testing/customresult.py 2010-04-13 10:36:35 +0000
94@@ -6,29 +6,12 @@
95 __metaclass__ = type
96 __all__ = [
97 'filter_tests',
98- 'list_tests',
99 'patch_find_tests',
100- 'patch_zope_testresult',
101- 'replace_list_of_tests',
102 ]
103
104 from unittest import TestSuite
105-from testtools import MultiTestResult, iterate_tests
106-from zope.testing.testrunner import find, formatter, runner
107-
108-
109-class NullOutputFormatter:
110- """A Zope test result OutputFormatter that prints *nothing*.
111-
112- This is used to suppress much of the output from the Zope testrunner.
113- """
114-
115- # Ideally, this would implement the interface of OutputFormatter and
116- # override all of the methods. Sadly, the interface is massive and not
117- # well-defined.
118-
119- def __getattr__(self, name):
120- return lambda *args, **kwargs: None
121+from testtools import iterate_tests
122+from zope.testing.testrunner import find
123
124
125 def patch_find_tests(hook):
126@@ -46,14 +29,6 @@
127 find.find_tests = find_tests
128
129
130-def list_tests(tests_by_layer_name):
131- """Print all test ids in the result of `testrunner.find_tests`."""
132- for suite in tests_by_layer_name.itervalues():
133- for test in iterate_tests(suite):
134- print test.id()
135- return {}
136-
137-
138 def filter_tests(list_name):
139 """Create a hook for `patch_find_tests` that filters tests based on id.
140
141@@ -74,41 +49,3 @@
142 result[layer_name] = new_suite
143 return result
144 return do_filter
145-
146-
147-def patch_zope_testresult(result):
148- """Patch the Zope test result factory so that our test result is used.
149-
150- We need to keep using the Zope test result object since it does all sorts
151- of crazy things to make layers work. So that the output of our result
152- object is used, we disable the output of the Zope test result object.
153-
154- :param result: A TestResult instance.
155- """
156- old_zope_factory = runner.TestResult
157- def zope_result_factory(options, tests, layer_name=None):
158- zope_result = old_zope_factory(options, tests, layer_name=layer_name)
159- if isinstance(zope_result, MultiTestResult):
160- return zope_result
161- else:
162- zope_result.options.output = NullOutputFormatter()
163- return MultiTestResult(result, zope_result)
164- runner.TestResult = zope_result_factory
165-
166-
167-def replace_list_of_tests(out_file):
168- """Replace OutputFormatter.list_of_tests.
169-
170- This is so we can obtain the list of tests that zope.testing
171- thinks should be run, after considering layers, etc. It also
172- prints test.id() rather than str(test).
173-
174- :param out_file: A writeable file where the list IDs can be
175- written to.
176- """
177- def list_of_tests(formatter, tests, layer_name):
178- """Report a list of test ids."""
179- print "Saving %s tests." % layer_name
180- for test in tests:
181- out_file.write(test.id() + "\n")
182- formatter.OutputFormatter.list_of_tests = list_of_tests
183
184=== removed symlink 'lib/subunit'
185=== target was u'../sourcecode/subunit/python/subunit'
186=== modified file 'utilities/sourcedeps.conf'
187--- utilities/sourcedeps.conf 2010-04-09 06:10:36 +0000
188+++ utilities/sourcedeps.conf 2010-04-13 10:36:35 +0000
189@@ -12,7 +12,6 @@
190 old_xmlplus lp:~launchpad-pqm/dtdparser/trunk;revno=4
191 pygettextpo lp:~launchpad-pqm/pygettextpo/trunk;revno=23
192 pygpgme lp:~launchpad-pqm/pygpgme/devel;revno=48
193-subunit lp:~launchpad-pqm/subunit/trunk;revno=61
194 subvertpy lp:~launchpad-pqm/subvertpy/trunk;revno=2040
195 testresources lp:~launchpad-pqm/testresources/dev;revno=16
196 shipit lp:~launchpad-pqm/shipit/trunk;revno=8904 optional
197
198=== modified file 'versions.cfg'
199--- versions.cfg 2010-03-25 18:06:39 +0000
200+++ versions.cfg 2010-04-13 10:36:35 +0000
201@@ -152,7 +152,7 @@
202 zope.app.server = 3.4.2
203 # not in ZTK
204 zope.app.session = 3.6.0
205-zope.app.testing = 3.7.3
206+zope.app.testing = 3.7.5
207 zope.app.wsgi = 3.6.0
208 # not in ZTK
209 zope.app.zapi = 3.4.1
210@@ -165,7 +165,7 @@
211 zope.browserpage = 3.9.0
212 zope.browserresource = 3.9.0
213 zope.cachedescriptors = 3.5.0
214-zope.component = 3.7.1
215+zope.component = 3.9.3
216 zope.componentvocabulary = 1.0
217 zope.configuration = 3.6.0
218 zope.container = 3.9.0
219@@ -205,7 +205,7 @@
220 zope.schema = 3.5.4
221 zope.security = 3.7.1
222 zope.securitypolicy = 3.6.1
223-zope.sendmail = 3.6.0
224+zope.sendmail = 3.7.1
225 zope.server = 3.6.1
226 zope.session = 3.9.1
227 zope.site = 3.7.0
228@@ -214,7 +214,7 @@
229 zope.tal = 3.5.1
230 zope.tales = 3.4.0
231 zope.testbrowser = 3.7.0a1
232-zope.testing = 3.8.1
233+zope.testing = 3.9.4
234 zope.thread = 3.4
235 zope.traversing = 3.8.0
236 zope.viewlet = 3.6.1