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

Proposed by Jonathan Lange
Status: Merged
Approved by: Jonathan Lange
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 Approve
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.
Revision history for this message
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
=== modified file 'buildout-templates/bin/test.in'
--- buildout-templates/bin/test.in 2010-02-24 16:44:39 +0000
+++ buildout-templates/bin/test.in 2010-04-13 10:36:35 +0000
@@ -97,6 +97,9 @@
97 'ignore', 'twisted.python.plugin', DeprecationWarning,97 'ignore', 'twisted.python.plugin', DeprecationWarning,
98 )98 )
99warnings.filterwarnings(99warnings.filterwarnings(
100 'ignore', 'zope.testing.doctest', DeprecationWarning,
101 )
102warnings.filterwarnings(
100 'ignore', 'bzrlib.*was deprecated', DeprecationWarning103 'ignore', 'bzrlib.*was deprecated', DeprecationWarning
101)104)
102# The next one is caused by a lamosity in python-openid. The following change105# The next one is caused by a lamosity in python-openid. The following change
@@ -164,14 +167,7 @@
164os.listdir = listdir167os.listdir = listdir
165168
166169
167from canonical.testing.customresult import (170from canonical.testing.customresult import filter_tests, patch_find_tests
168 filter_tests,
169 list_tests,
170 patch_find_tests,
171 patch_zope_testresult,
172 replace_list_of_tests,
173 )
174from subunit import TestProtocolClient
175171
176172
177if __name__ == '__main__':173if __name__ == '__main__':
@@ -195,41 +191,10 @@
195 options.parser.add_option(191 options.parser.add_option(
196 '--load-list', type=str, action='callback', callback=load_list)192 '--load-list', type=str, action='callback', callback=load_list)
197193
198 def list_test_option(option, opt, value, parser):
199 patch_find_tests(list_tests)
200 options.parser.add_option(
201 '--list', action='callback', callback=list_test_option)
202
203 def save_list_test_option(option, opt, value, parser):
204 # Replace zope.testing's list_of_tests() method with our own
205 # that prints test IDs to the file given at the command line.
206 replace_list_of_tests(open(value, 'wb'))
207 # Get zope.testing to produce a listing. This works because
208 # this option parser is actually called twice, once here and
209 # once again within zope.testing.
210 args.append('--list-tests')
211 options.parser.add_option(
212 '--save-list', action='callback',
213 callback=save_list_test_option, type="str")
214
215 def use_subunit(option, opt, value, parser):
216 patch_zope_testresult(TestProtocolClient(sys.stdout))
217 options.parser.add_option(
218 '--subunit', action='callback', callback=use_subunit)
219
220 # tests_pattern is a regexp, so the parsed value is hard to compare194 # tests_pattern is a regexp, so the parsed value is hard to compare
221 # with the default value in the loop below.195 # with the default value in the loop below.
222 options.parser.defaults['tests_pattern'] = defaults['tests_pattern']196 options.parser.defaults['tests_pattern'] = defaults['tests_pattern']
223 local_options = options.get_options(args=args)197 local_options = options.get_options(args=args)
224 if os.getenv("SUBUNIT_FORMATTER"):
225 try:
226 from subunit import get_default_formatter
227 except ImportError:
228 # Not a new enough subunit
229 pass
230 else:
231 stream = get_default_formatter()
232 patch_zope_testresult(TestProtocolClient(stream))
233 # Set our default options, if the options aren't specified.198 # Set our default options, if the options aren't specified.
234 for name, value in defaults.items():199 for name, value in defaults.items():
235 parsed_option = getattr(local_options, name)200 parsed_option = getattr(local_options, name)
236201
=== modified file 'lib/canonical/launchpad/webapp/metazcml.py'
--- lib/canonical/launchpad/webapp/metazcml.py 2010-01-09 00:27:05 +0000
+++ lib/canonical/launchpad/webapp/metazcml.py 2010-04-13 10:36:35 +0000
@@ -8,11 +8,11 @@
8import zope.app.form.browser.metadirectives8import zope.app.form.browser.metadirectives
9import zope.app.publisher.browser.metadirectives9import zope.app.publisher.browser.metadirectives
10import zope.configuration.config10import zope.configuration.config
11from zope.app.component.metaconfigure import PublicPermission, view
12from zope.app.file.image import Image11from zope.app.file.image import Image
13from zope.app.pagetemplate.engine import TrustedEngine12from zope.app.pagetemplate.engine import TrustedEngine
14from zope.component import getUtility13from zope.component import getUtility
15from zope.component.zcml import adapter, handler, utility14from zope.component.security import PublicPermission
15from zope.component.zcml import adapter, handler, utility, view
16from zope.configuration.fields import (16from zope.configuration.fields import (
17 GlobalInterface, GlobalObject, Path, PythonIdentifier, Tokens)17 GlobalInterface, GlobalObject, Path, PythonIdentifier, Tokens)
18from zope.interface import Interface, implements18from zope.interface import Interface, implements
1919
=== modified file 'lib/canonical/testing/customresult.py'
--- lib/canonical/testing/customresult.py 2009-12-07 10:24:26 +0000
+++ lib/canonical/testing/customresult.py 2010-04-13 10:36:35 +0000
@@ -6,29 +6,12 @@
6__metaclass__ = type6__metaclass__ = type
7__all__ = [7__all__ = [
8 'filter_tests',8 'filter_tests',
9 'list_tests',
10 'patch_find_tests',9 'patch_find_tests',
11 'patch_zope_testresult',
12 'replace_list_of_tests',
13 ]10 ]
1411
15from unittest import TestSuite12from unittest import TestSuite
16from testtools import MultiTestResult, iterate_tests13from testtools import iterate_tests
17from zope.testing.testrunner import find, formatter, runner14from zope.testing.testrunner import find
18
19
20class NullOutputFormatter:
21 """A Zope test result OutputFormatter that prints *nothing*.
22
23 This is used to suppress much of the output from the Zope testrunner.
24 """
25
26 # Ideally, this would implement the interface of OutputFormatter and
27 # override all of the methods. Sadly, the interface is massive and not
28 # well-defined.
29
30 def __getattr__(self, name):
31 return lambda *args, **kwargs: None
3215
3316
34def patch_find_tests(hook):17def patch_find_tests(hook):
@@ -46,14 +29,6 @@
46 find.find_tests = find_tests29 find.find_tests = find_tests
4730
4831
49def list_tests(tests_by_layer_name):
50 """Print all test ids in the result of `testrunner.find_tests`."""
51 for suite in tests_by_layer_name.itervalues():
52 for test in iterate_tests(suite):
53 print test.id()
54 return {}
55
56
57def filter_tests(list_name):32def filter_tests(list_name):
58 """Create a hook for `patch_find_tests` that filters tests based on id.33 """Create a hook for `patch_find_tests` that filters tests based on id.
5934
@@ -74,41 +49,3 @@
74 result[layer_name] = new_suite49 result[layer_name] = new_suite
75 return result50 return result
76 return do_filter51 return do_filter
77
78
79def patch_zope_testresult(result):
80 """Patch the Zope test result factory so that our test result is used.
81
82 We need to keep using the Zope test result object since it does all sorts
83 of crazy things to make layers work. So that the output of our result
84 object is used, we disable the output of the Zope test result object.
85
86 :param result: A TestResult instance.
87 """
88 old_zope_factory = runner.TestResult
89 def zope_result_factory(options, tests, layer_name=None):
90 zope_result = old_zope_factory(options, tests, layer_name=layer_name)
91 if isinstance(zope_result, MultiTestResult):
92 return zope_result
93 else:
94 zope_result.options.output = NullOutputFormatter()
95 return MultiTestResult(result, zope_result)
96 runner.TestResult = zope_result_factory
97
98
99def replace_list_of_tests(out_file):
100 """Replace OutputFormatter.list_of_tests.
101
102 This is so we can obtain the list of tests that zope.testing
103 thinks should be run, after considering layers, etc. It also
104 prints test.id() rather than str(test).
105
106 :param out_file: A writeable file where the list IDs can be
107 written to.
108 """
109 def list_of_tests(formatter, tests, layer_name):
110 """Report a list of test ids."""
111 print "Saving %s tests." % layer_name
112 for test in tests:
113 out_file.write(test.id() + "\n")
114 formatter.OutputFormatter.list_of_tests = list_of_tests
11552
=== removed symlink 'lib/subunit'
=== target was u'../sourcecode/subunit/python/subunit'
=== modified file 'utilities/sourcedeps.conf'
--- utilities/sourcedeps.conf 2010-04-09 06:10:36 +0000
+++ utilities/sourcedeps.conf 2010-04-13 10:36:35 +0000
@@ -12,7 +12,6 @@
12old_xmlplus lp:~launchpad-pqm/dtdparser/trunk;revno=412old_xmlplus lp:~launchpad-pqm/dtdparser/trunk;revno=4
13pygettextpo lp:~launchpad-pqm/pygettextpo/trunk;revno=2313pygettextpo lp:~launchpad-pqm/pygettextpo/trunk;revno=23
14pygpgme lp:~launchpad-pqm/pygpgme/devel;revno=4814pygpgme lp:~launchpad-pqm/pygpgme/devel;revno=48
15subunit lp:~launchpad-pqm/subunit/trunk;revno=61
16subvertpy lp:~launchpad-pqm/subvertpy/trunk;revno=204015subvertpy lp:~launchpad-pqm/subvertpy/trunk;revno=2040
17testresources lp:~launchpad-pqm/testresources/dev;revno=1616testresources lp:~launchpad-pqm/testresources/dev;revno=16
18shipit lp:~launchpad-pqm/shipit/trunk;revno=8904 optional17shipit lp:~launchpad-pqm/shipit/trunk;revno=8904 optional
1918
=== modified file 'versions.cfg'
--- versions.cfg 2010-03-25 18:06:39 +0000
+++ versions.cfg 2010-04-13 10:36:35 +0000
@@ -152,7 +152,7 @@
152zope.app.server = 3.4.2152zope.app.server = 3.4.2
153# not in ZTK153# not in ZTK
154zope.app.session = 3.6.0154zope.app.session = 3.6.0
155zope.app.testing = 3.7.3155zope.app.testing = 3.7.5
156zope.app.wsgi = 3.6.0156zope.app.wsgi = 3.6.0
157# not in ZTK157# not in ZTK
158zope.app.zapi = 3.4.1158zope.app.zapi = 3.4.1
@@ -165,7 +165,7 @@
165zope.browserpage = 3.9.0165zope.browserpage = 3.9.0
166zope.browserresource = 3.9.0166zope.browserresource = 3.9.0
167zope.cachedescriptors = 3.5.0167zope.cachedescriptors = 3.5.0
168zope.component = 3.7.1168zope.component = 3.9.3
169zope.componentvocabulary = 1.0169zope.componentvocabulary = 1.0
170zope.configuration = 3.6.0170zope.configuration = 3.6.0
171zope.container = 3.9.0171zope.container = 3.9.0
@@ -205,7 +205,7 @@
205zope.schema = 3.5.4205zope.schema = 3.5.4
206zope.security = 3.7.1206zope.security = 3.7.1
207zope.securitypolicy = 3.6.1207zope.securitypolicy = 3.6.1
208zope.sendmail = 3.6.0208zope.sendmail = 3.7.1
209zope.server = 3.6.1209zope.server = 3.6.1
210zope.session = 3.9.1210zope.session = 3.9.1
211zope.site = 3.7.0211zope.site = 3.7.0
@@ -214,7 +214,7 @@
214zope.tal = 3.5.1214zope.tal = 3.5.1
215zope.tales = 3.4.0215zope.tales = 3.4.0
216zope.testbrowser = 3.7.0a1216zope.testbrowser = 3.7.0a1
217zope.testing = 3.8.1217zope.testing = 3.9.4
218zope.thread = 3.4218zope.thread = 3.4
219zope.traversing = 3.8.0219zope.traversing = 3.8.0
220zope.viewlet = 3.6.1220zope.viewlet = 3.6.1