Merge lp:~bac/launchpad/bug-682772 into lp:launchpad

Proposed by Brad Crittenden
Status: Merged
Approved by: Gary Poster
Approved revision: no longer in the source branch.
Merged at revision: 15411
Proposed branch: lp:~bac/launchpad/bug-682772
Merge into: lp:launchpad
Diff against target: 578 lines (+116/-86)
18 files modified
lib/lp/answers/tests/test_doc.py (+6/-3)
lib/lp/bugs/tests/test_bugcontact.py (+5/-1)
lib/lp/bugs/tests/test_buglinktarget.py (+5/-3)
lib/lp/bugs/tests/test_bugtarget.py (+5/-1)
lib/lp/bugs/tests/test_doc.py (+13/-2)
lib/lp/bugs/tests/test_structuralsubscriptiontarget.py (+5/-1)
lib/lp/coop/answersbugs/tests/test_doc.py (+14/-13)
lib/lp/registry/tests/test_distribution.py (+4/-3)
lib/lp/registry/tests/test_distroseries.py (+27/-15)
lib/lp/registry/tests/test_doc.py (+3/-0)
lib/lp/services/verification/browser/tests/test_logintoken_corner_cases.py (+0/-25)
lib/lp/services/webservice/tests/test_doc.py (+2/-1)
lib/lp/soyuz/tests/test_doc.py (+1/-0)
lib/lp/testing/pages.py (+4/-3)
lib/lp/testing/systemdocs.py (+14/-11)
lib/lp/testing/tests/test_inlinetests.py (+1/-1)
lib/lp/testing/tests/test_systemdocs.py (+2/-2)
versions.cfg (+5/-1)
To merge this branch: bzr merge lp:~bac/launchpad/bug-682772
Reviewer Review Type Date Requested Status
Gary Poster (community) Approve
Review via email: mp+108983@code.launchpad.net

Commit message

Make all tests have a unique id.

Description of the change

= Summary =

Correct doctests that are reused with the same id.

Fix the LayeredDoctFileSuite factory to accept another parameter that
is used to augment the filenames into new ids in order to make them
unique.

Note that nothing currently ensure the tests are unique as it is a
volunteer effort. See the companion bug 682771 for that effort.

Also fixed a pair of unit tests that were run multiple times due to
the base class being discovered upon import.

== Pre-implementation notes ==

Talks with Gary.

== Implementation details ==

As above.

== Tests ==

== Demo and Q/A ==

Downloading this file http://pastebin.ubuntu.com/1027090/ as
finddups.py, run...

bin/test --list > list.out; python finddups.py > dups.txt

...and ensure there are not dupes. Well, there is the
twisted/.../runTest dupe but that one is being ignored as beyond the
scope of this change.

= Launchpad lint =

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/bugs/tests/test_bugtarget.py
  lib/lp/testing/pages.py
  lib/lp/registry/tests/test_distroseries.py
  lib/lp/answers/tests/test_doc.py
  versions.cfg
  lib/lp/soyuz/tests/test_doc.py
  lib/lp/bugs/tests/test_buglinktarget.py
  lib/lp/bugs/tests/test_doc.py
  lib/lp/registry/tests/test_doc.py
  lib/lp/bugs/tests/test_structuralsubscriptiontarget.py
  lib/lp/testing/systemdocs.py
  lib/lp/services/webservice/tests/test_doc.py
  lib/lp/coop/answersbugs/tests/test_doc.py
  lib/lp/registry/tests/test_distribution.py
  lib/lp/testing/tests/test_inlinetests.py
  lib/lp/bugs/tests/test_bugcontact.py

To post a comment you must log in.
Revision history for this message
Gary Poster (gary) wrote :

Cool, thank you.

I asked about whether id_extensions ought to be id_extension, since you only ever provide one, but you gave me a compelling case in which this would be reasonable ("if someone called the factory with multiple paths then there would need to a 1:1 correspondence to id_extensions") so I'm fine with it.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/answers/tests/test_doc.py'
2--- lib/lp/answers/tests/test_doc.py 2012-01-01 02:58:52 +0000
3+++ lib/lp/answers/tests/test_doc.py 2012-06-13 20:57:19 +0000
4@@ -87,10 +87,13 @@
5
6 suite = unittest.TestSuite()
7 for name, setup_func in targets:
8+ test_path = os.path.join(os.path.pardir, 'doc', test_file)
9+ id_ext = "%s-%s" % (test_file, name)
10 test = LayeredDocFileSuite(
11- os.path.join(os.path.pardir, 'doc', test_file),
12- setUp=setup_func, tearDown=tearDown,
13- layer=DatabaseFunctionalLayer)
14+ test_path,
15+ id_extensions=[id_ext],
16+ setUp=setup_func, tearDown=tearDown,
17+ layer=DatabaseFunctionalLayer)
18 suite.addTest(test)
19 return suite
20
21
22=== modified file 'lib/lp/bugs/tests/test_bugcontact.py'
23--- lib/lp/bugs/tests/test_bugcontact.py 2012-01-01 02:58:52 +0000
24+++ lib/lp/bugs/tests/test_bugcontact.py 2012-06-13 20:57:19 +0000
25@@ -27,8 +27,12 @@
26 distributionSetUp,
27 ]
28
29+ testname = 'has-bug-supervisor.txt'
30 for setUpMethod in setUpMethods:
31- test = LayeredDocFileSuite('has-bug-supervisor.txt',
32+ id_ext = "%s-%s" % (testname, setUpMethod.func_name)
33+ test = LayeredDocFileSuite(
34+ testname,
35+ id_extensions=[id_ext],
36 setUp=setUpMethod, tearDown=tearDown,
37 layer=DatabaseFunctionalLayer)
38 suite.addTest(test)
39
40=== modified file 'lib/lp/bugs/tests/test_buglinktarget.py'
41--- lib/lp/bugs/tests/test_buglinktarget.py 2012-01-01 02:58:52 +0000
42+++ lib/lp/bugs/tests/test_buglinktarget.py 2012-06-13 20:57:19 +0000
43@@ -51,9 +51,11 @@
44 ]
45
46 for name, setUpMethod in targets:
47- test = LayeredDocFileSuite('buglinktarget.txt',
48- setUp=setUpMethod, tearDown=tearDown,
49- layer=LaunchpadFunctionalLayer)
50+ test = LayeredDocFileSuite(
51+ 'buglinktarget.txt',
52+ id_extensions=[name],
53+ setUp=setUpMethod, tearDown=tearDown,
54+ layer=LaunchpadFunctionalLayer)
55 suite.addTest(test)
56 return suite
57
58
59=== modified file 'lib/lp/bugs/tests/test_bugtarget.py'
60--- lib/lp/bugs/tests/test_bugtarget.py 2012-04-17 08:01:35 +0000
61+++ lib/lp/bugs/tests/test_bugtarget.py 2012-06-13 20:57:19 +0000
62@@ -212,8 +212,12 @@
63 distributionSeriesSetUp,
64 ]
65
66+ testname = 'bugtarget-questiontarget.txt'
67 for setUpMethod in setUpMethods:
68- test = LayeredDocFileSuite('bugtarget-questiontarget.txt',
69+ id_ext = "%s-%s" % (testname, setUpMethod.func_name)
70+ test = LayeredDocFileSuite(
71+ testname,
72+ id_extensions=[id_ext],
73 setUp=setUpMethod, tearDown=tearDown,
74 layer=DatabaseFunctionalLayer)
75 suite.addTest(test)
76
77=== modified file 'lib/lp/bugs/tests/test_doc.py'
78--- lib/lp/bugs/tests/test_doc.py 2012-03-27 13:41:38 +0000
79+++ lib/lp/bugs/tests/test_doc.py 2012-06-13 20:57:19 +0000
80@@ -141,24 +141,28 @@
81 ),
82 'bugnotificationrecipients.txt-uploader': LayeredDocFileSuite(
83 '../doc/bugnotificationrecipients.txt',
84+ id_extensions=['bugnotificationrecipients.txt-uploader'],
85 setUp=uploaderBugsSetUp,
86 tearDown=uploaderBugsTearDown,
87 layer=LaunchpadZopelessLayer
88 ),
89 'bugnotificationrecipients.txt-queued': LayeredDocFileSuite(
90 '../doc/bugnotificationrecipients.txt',
91+ id_extensions=['bugnotificationrecipients.txt-queued'],
92 setUp=uploadQueueSetUp,
93 tearDown=uploadQueueTearDown,
94 layer=LaunchpadZopelessLayer
95 ),
96 'bugnotificationrecipients.txt-branchscanner': LayeredDocFileSuite(
97 '../doc/bugnotificationrecipients.txt',
98+ id_extensions=['bugnotificationrecipients.txt-branchscanner'],
99 setUp=branchscannerBugsSetUp,
100 tearDown=tearDown,
101 layer=LaunchpadZopelessLayer
102 ),
103 'bugnotificationrecipients.txt': LayeredDocFileSuite(
104 '../doc/bugnotificationrecipients.txt',
105+ id_extensions=['bugnotificationrecipients.txt'],
106 setUp=lobotomizeSteveASetUp, tearDown=tearDown,
107 layer=LaunchpadFunctionalLayer
108 ),
109@@ -184,12 +188,14 @@
110 ),
111 'bug-set-status.txt': LayeredDocFileSuite(
112 '../doc/bug-set-status.txt',
113+ id_extensions=['bug-set-status.txt'],
114 setUp=uploadQueueSetUp,
115 tearDown=uploadQueueTearDown,
116 layer=LaunchpadZopelessLayer
117 ),
118 'bug-set-status.txt-uploader': LayeredDocFileSuite(
119 '../doc/bug-set-status.txt',
120+ id_extensions=['bug-set-status.txt-uploader'],
121 setUp=uploaderBugsSetUp,
122 tearDown=uploaderBugsTearDown,
123 layer=LaunchpadZopelessLayer
124@@ -202,23 +208,27 @@
125 ),
126 'bugmessage.txt': LayeredDocFileSuite(
127 '../doc/bugmessage.txt',
128+ id_extensions=['bugmessage.txt'],
129 setUp=noPrivSetUp, tearDown=tearDown,
130 layer=LaunchpadFunctionalLayer
131 ),
132 'bugmessage.txt-queued': LayeredDocFileSuite(
133 '../doc/bugmessage.txt',
134+ id_extensions=['bugmessage.txt-queued'],
135 setUp=uploadQueueSetUp,
136 tearDown=uploadQueueTearDown,
137 layer=LaunchpadZopelessLayer
138 ),
139 'bugmessage.txt-uploader': LayeredDocFileSuite(
140 '../doc/bugmessage.txt',
141+ id_extensions=['bugmessage.txt-uploader'],
142 setUp=uploaderSetUp,
143 tearDown=tearDown,
144 layer=LaunchpadZopelessLayer
145 ),
146 'bugmessage.txt-checkwatches': LayeredDocFileSuite(
147 '../doc/bugmessage.txt',
148+ id_extensions=['bugmessage.txt-checkwatches'],
149 setUp=checkwatchesSetUp,
150 tearDown=tearDown,
151 layer=LaunchpadZopelessLayer
152@@ -429,11 +439,13 @@
153 ),
154 'bug-set-status.txt-processmail': LayeredDocFileSuite(
155 '../doc/bug-set-status.txt',
156+ id_extensions=['bug-set-status.txt-processmail'],
157 setUp=bugSetStatusSetUp, tearDown=tearDown,
158 layer=ProcessMailLayer,
159 stdout_logging=False),
160 'bugmessage.txt-processmail': LayeredDocFileSuite(
161 '../doc/bugmessage.txt',
162+ id_extensions=['bugmessage.txt-processmail'],
163 setUp=bugmessageSetUp, tearDown=tearDown,
164 layer=ProcessMailLayer,
165 stdout_logging=False),
166@@ -463,8 +475,7 @@
167 )
168
169 # Add special needs tests
170- for key in sorted(special):
171- special_suite = special[key]
172+ for key, special_suite in sorted(special.items()):
173 suite.addTest(special_suite)
174
175 # Add tests using default setup/teardown
176
177=== modified file 'lib/lp/bugs/tests/test_structuralsubscriptiontarget.py'
178--- lib/lp/bugs/tests/test_structuralsubscriptiontarget.py 2012-01-01 02:58:52 +0000
179+++ lib/lp/bugs/tests/test_structuralsubscriptiontarget.py 2012-06-13 20:57:19 +0000
180@@ -557,8 +557,12 @@
181 distroSeriesSourcePackageSetUp,
182 ]
183
184+ testname = 'structural-subscription-target.txt'
185 for setUpMethod in setUpMethods:
186- test = LayeredDocFileSuite('structural-subscription-target.txt',
187+ id_ext = "%s-%s" % (testname, setUpMethod.func_name)
188+ test = LayeredDocFileSuite(
189+ testname,
190+ id_extensions=[id_ext],
191 setUp=setUpMethod, tearDown=tearDown,
192 layer=LaunchpadFunctionalLayer)
193 suite.addTest(test)
194
195=== modified file 'lib/lp/coop/answersbugs/tests/test_doc.py'
196--- lib/lp/coop/answersbugs/tests/test_doc.py 2012-01-20 15:42:44 +0000
197+++ lib/lp/coop/answersbugs/tests/test_doc.py 2012-06-13 20:57:19 +0000
198@@ -106,20 +106,21 @@
199 setUp=bugLinkedToQuestionSetUp, tearDown=tearDown,
200 layer=DatabaseFunctionalLayer),
201 'notifications-linked-bug.txt': LayeredDocFileSuite(
202- 'notifications-linked-bug.txt',
203- setUp=bugLinkedToQuestionSetUp, tearDown=tearDown,
204- layer=DatabaseFunctionalLayer),
205- 'notifications-linked-bug.txt-uploader':
206- LayeredDocFileSuite(
207- 'notifications-linked-bug.txt',
208- setUp=uploaderBugLinkedToQuestionSetUp,
209- tearDown=tearDown,
210- layer=LaunchpadZopelessLayer),
211+ 'notifications-linked-bug.txt',
212+ setUp=bugLinkedToQuestionSetUp, tearDown=tearDown,
213+ layer=DatabaseFunctionalLayer),
214+ 'notifications-linked-bug.txt-uploader': LayeredDocFileSuite(
215+ 'notifications-linked-bug.txt',
216+ id_extensions=['notifications-linked-bug.txt-uploader'],
217+ setUp=uploaderBugLinkedToQuestionSetUp,
218+ tearDown=tearDown,
219+ layer=LaunchpadZopelessLayer),
220 'notifications-linked-bug.txt-queued': LayeredDocFileSuite(
221- 'notifications-linked-bug.txt',
222- setUp=uploadQueueBugLinkedToQuestionSetUp,
223- tearDown=tearDown,
224- layer=LaunchpadZopelessLayer),
225+ 'notifications-linked-bug.txt',
226+ id_extensions=['notifications-linked-bug.txt-queued'],
227+ setUp=uploadQueueBugLinkedToQuestionSetUp,
228+ tearDown=tearDown,
229+ layer=LaunchpadZopelessLayer),
230 }
231
232
233
234=== modified file 'lib/lp/registry/tests/test_distribution.py'
235--- lib/lp/registry/tests/test_distribution.py 2012-06-04 16:13:51 +0000
236+++ lib/lp/registry/tests/test_distribution.py 2012-06-13 20:57:19 +0000
237@@ -44,7 +44,7 @@
238 )
239 from lp.registry.interfaces.series import SeriesStatus
240 from lp.registry.tests.test_distroseries import (
241- TestDistroSeriesCurrentSourceReleases,
242+ CurrentSourceReleasesMixin,
243 )
244 from lp.services.database.constants import UTC_NOW
245 from lp.services.propertycache import get_property_cache
246@@ -56,6 +56,7 @@
247 celebrity_logged_in,
248 login_person,
249 person_logged_in,
250+ TestCase,
251 TestCaseWithFactory,
252 WebServiceTestCase,
253 )
254@@ -278,7 +279,7 @@
255
256
257 class TestDistributionCurrentSourceReleases(
258- TestDistroSeriesCurrentSourceReleases):
259+ CurrentSourceReleasesMixin, TestCase):
260 """Test for Distribution.getCurrentSourceReleases().
261
262 This works in the same way as
263@@ -290,7 +291,7 @@
264 release_interface = IDistributionSourcePackageRelease
265
266 @property
267- def test_target(self):
268+ def target(self):
269 return self.distribution
270
271 def test_which_distroseries_does_not_matter(self):
272
273=== modified file 'lib/lp/registry/tests/test_distroseries.py'
274--- lib/lp/registry/tests/test_distroseries.py 2012-04-05 15:50:01 +0000
275+++ lib/lp/registry/tests/test_distroseries.py 2012-06-13 20:57:19 +0000
276@@ -5,6 +5,10 @@
277
278 __metaclass__ = type
279
280+__all__ = [
281+ 'CurrentSourceReleasesMixin',
282+ ]
283+
284 from datetime import timedelta
285 from logging import getLogger
286
287@@ -48,28 +52,24 @@
288 )
289
290
291-class TestDistroSeriesCurrentSourceReleases(TestCase):
292- """Test for DistroSeries.getCurrentSourceReleases()."""
293-
294- layer = LaunchpadFunctionalLayer
295- release_interface = IDistroSeriesSourcePackageRelease
296-
297+class CurrentSourceReleasesMixin:
298+ """Mixin class for current source release tests.
299+
300+ Used by tests of DistroSeries and Distribution. The mixin must not extend
301+ TestCase or it will be run by other modules when imported.
302+ """
303 def setUp(self):
304 # Log in as an admin, so that we can create distributions.
305- super(TestDistroSeriesCurrentSourceReleases, self).setUp()
306+ super(CurrentSourceReleasesMixin, self).setUp()
307 login('foo.bar@canonical.com')
308 self.publisher = SoyuzTestPublisher()
309 self.factory = self.publisher.factory
310 self.development_series = self.publisher.setUpDefaultDistroSeries()
311 self.distribution = self.development_series.distribution
312- self.published_package = self.test_target.getSourcePackage(
313+ self.published_package = self.target.getSourcePackage(
314 self.publisher.default_package_name)
315 login(ANONYMOUS)
316
317- @property
318- def test_target(self):
319- return self.development_series
320-
321 def assertCurrentVersion(self, expected_version, package_name=None):
322 """Assert the current version of a package is the expected one.
323
324@@ -80,8 +80,8 @@
325 """
326 if package_name is None:
327 package_name = self.publisher.default_package_name
328- package = self.test_target.getSourcePackage(package_name)
329- releases = self.test_target.getCurrentSourceReleases(
330+ package = self.target.getSourcePackage(package_name)
331+ releases = self.target.getCurrentSourceReleases(
332 [package.sourcepackagename])
333 self.assertEqual(releases[package].version, expected_version)
334
335@@ -95,7 +95,7 @@
336 # source package is used as the key, with
337 # a DistroSeriesSourcePackageRelease as the values.
338 self.publisher.getPubSource(version='0.9')
339- releases = self.test_target.getCurrentSourceReleases(
340+ releases = self.target.getCurrentSourceReleases(
341 [self.published_package.sourcepackagename])
342 self.assertTrue(self.published_package in releases)
343 self.assertTrue(self.release_interface.providedBy(
344@@ -170,6 +170,18 @@
345 self.assertEqual(releases[bar_package].version, '1.0')
346
347
348+class TestDistroSeriesCurrentSourceReleases(
349+ CurrentSourceReleasesMixin, TestCase):
350+ """Test for DistroSeries.getCurrentSourceReleases()."""
351+
352+ layer = LaunchpadFunctionalLayer
353+ release_interface = IDistroSeriesSourcePackageRelease
354+
355+ @property
356+ def target(self):
357+ return self.development_series
358+
359+
360 class TestDistroSeries(TestCaseWithFactory):
361
362 layer = DatabaseFunctionalLayer
363
364=== modified file 'lib/lp/registry/tests/test_doc.py'
365--- lib/lp/registry/tests/test_doc.py 2012-01-01 02:58:52 +0000
366+++ lib/lp/registry/tests/test_doc.py 2012-06-13 20:57:19 +0000
367@@ -85,6 +85,7 @@
368 ),
369 'mailinglist-xmlrpc.txt-external': LayeredDocFileSuite(
370 '../doc/mailinglist-xmlrpc.txt',
371+ id_extensions=['mailinglist-xmlrpc.txt-external'],
372 setUp=mailingListXMLRPCExternalSetUp,
373 tearDown=tearDown,
374 layer=LaunchpadFunctionalLayer,
375@@ -97,6 +98,7 @@
376 ),
377 'mailinglist-subscriptions-xmlrpc.txt-external': LayeredDocFileSuite(
378 '../doc/mailinglist-subscriptions-xmlrpc.txt',
379+ id_extensions=['mailinglist-subscriptions-xmlrpc.txt-external'],
380 setUp=mailingListXMLRPCExternalSetUp,
381 tearDown=tearDown,
382 layer=LaunchpadFunctionalLayer,
383@@ -115,6 +117,7 @@
384 ),
385 'message-holds-xmlrpc.txt-external': LayeredDocFileSuite(
386 '../doc/message-holds-xmlrpc.txt',
387+ id_extensions=['message-holds-xmlrpc.txt-external'],
388 setUp=mailingListXMLRPCExternalSetUp,
389 tearDown=tearDown,
390 layer=LaunchpadFunctionalLayer,
391
392=== removed file 'lib/lp/services/verification/browser/tests/test_logintoken_corner_cases.py'
393--- lib/lp/services/verification/browser/tests/test_logintoken_corner_cases.py 2011-12-28 17:03:06 +0000
394+++ lib/lp/services/verification/browser/tests/test_logintoken_corner_cases.py 1970-01-01 00:00:00 +0000
395@@ -1,25 +0,0 @@
396-# Copyright 2009 Canonical Ltd. This software is licensed under the
397-# GNU Affero General Public License version 3 (see the file LICENSE).
398-
399-"""Test harness for running the logintoken-corner-cases.txt tests."""
400-
401-__metaclass__ = type
402-
403-import unittest
404-
405-from lp.testing.layers import LaunchpadFunctionalLayer
406-from lp.testing.systemdocs import (
407- LayeredDocFileSuite,
408- setUp,
409- tearDown,
410- )
411-
412-
413-def test_suite():
414- suite = unittest.TestSuite()
415-
416- test = LayeredDocFileSuite('logintoken-corner-cases.txt',
417- setUp=setUp, tearDown=tearDown,
418- layer=LaunchpadFunctionalLayer)
419- suite.addTest(test)
420- return suite
421
422=== modified file 'lib/lp/services/webservice/tests/test_doc.py'
423--- lib/lp/services/webservice/tests/test_doc.py 2012-01-01 02:58:52 +0000
424+++ lib/lp/services/webservice/tests/test_doc.py 2012-06-13 20:57:19 +0000
425@@ -39,8 +39,9 @@
426 '../doc/launchpadlib.txt',
427 layer=AppServerLayer,
428 setUp=browser.setUp, tearDown=browser.tearDown,),
429- 'launchpadlib2.txt': LayeredDocFileSuite(
430+ 'launchpadlib.txt-2': LayeredDocFileSuite(
431 '../doc/launchpadlib.txt',
432+ id_extensions=['launchpadlib.txt-2'],
433 layer=AppServerLayer,
434 setUp=browser.setUp, tearDown=browser.tearDown,),
435 }
436
437=== modified file 'lib/lp/soyuz/tests/test_doc.py'
438--- lib/lp/soyuz/tests/test_doc.py 2012-05-30 12:34:41 +0000
439+++ lib/lp/soyuz/tests/test_doc.py 2012-06-13 20:57:19 +0000
440@@ -132,6 +132,7 @@
441 ),
442 'closing-bugs-from-changelogs.txt-uploader': LayeredDocFileSuite(
443 '../doc/closing-bugs-from-changelogs.txt',
444+ id_extensions=['closing-bugs-from-changelogs.txt-uploader'],
445 setUp=uploaderBugsSetUp,
446 tearDown=uploaderBugsTearDown,
447 layer=LaunchpadZopelessLayer
448
449=== modified file 'lib/lp/testing/pages.py'
450--- lib/lp/testing/pages.py 2012-01-31 01:19:45 +0000
451+++ lib/lp/testing/pages.py 2012-06-13 20:57:19 +0000
452@@ -843,9 +843,10 @@
453 # Add tests to the suite individually.
454 if filenames:
455 checker = doctest.OutputChecker()
456+ paths=[os.path.join(storydir, filename)
457+ for filename in filenames]
458 suite.addTest(LayeredDocFileSuite(
459+ paths=paths,
460 package=package, checker=checker, stdout_logging=False,
461- layer=PageTestLayer, setUp=setUp,
462- *[os.path.join(storydir, filename)
463- for filename in filenames]))
464+ layer=PageTestLayer, setUp=setUp))
465 return suite
466
467=== modified file 'lib/lp/testing/systemdocs.py'
468--- lib/lp/testing/systemdocs.py 2011-12-30 06:14:56 +0000
469+++ lib/lp/testing/systemdocs.py 2012-06-13 20:57:19 +0000
470@@ -89,7 +89,7 @@
471 record.levelname, record.name, self.format(record))
472
473
474-def LayeredDocFileSuite(*paths, **kw):
475+def LayeredDocFileSuite(paths, id_extensions=None, **kw):
476 """Create a DocFileSuite, optionally applying a layer to it.
477
478 In addition to the standard DocFileSuite arguments, the following
479@@ -101,6 +101,10 @@
480 :param layer: A Zope test runner layer to apply to the tests (by
481 default no layer is applied).
482 """
483+ if not isinstance(paths, (tuple, list)):
484+ paths = [paths]
485+ if id_extensions is None:
486+ id_extensions = []
487 kw.setdefault('optionflags', default_optionflags)
488 kw.setdefault('parser', default_parser)
489
490@@ -142,14 +146,21 @@
491 if layer is not None:
492 suite.layer = layer
493
494- for test in suite:
495+ for i, test in enumerate(suite):
496 # doctest._module_relative_path() does not normalize paths. To make
497 # test selection simpler and reporting easier to read, normalize here.
498 test._dt_test.filename = os.path.normpath(test._dt_test.filename)
499 # doctest.DocFileTest insists on using the basename of the file as the
500 # test ID. This causes conflicts when two doctests have the same
501 # filename, so we patch the id() method on the test cases.
502- test.id = partial(lambda test: test._dt_test.filename, test)
503+ try:
504+ ext = id_extensions[i]
505+ newid = os.path.join(
506+ os.path.dirname(test._dt_test.filename),
507+ ext)
508+ test.id = partial(lambda x: x, newid)
509+ except IndexError:
510+ test.id = partial(lambda test: test._dt_test.filename, test)
511
512 return suite
513
514@@ -162,14 +173,6 @@
515
516 We do this because dict ordering is not guaranteed.
517 """
518- # XXX 2008-06-25 gmb:
519- # Once we move to Python 2.5 we won't need this, since dict
520- # ordering is guaranteed when __str__() is called.
521- item_string = '%r: %r'
522- item_strings = []
523- for key, value in sorted(dict.items()):
524- item_strings.append(item_string % (key, value))
525-
526 return '{%s}' % ', '.join(
527 "%r: %r" % (key, value) for key, value in sorted(dict.items()))
528
529
530=== modified file 'lib/lp/testing/tests/test_inlinetests.py'
531--- lib/lp/testing/tests/test_inlinetests.py 2012-01-01 02:58:52 +0000
532+++ lib/lp/testing/tests/test_inlinetests.py 2012-06-13 20:57:19 +0000
533@@ -16,8 +16,8 @@
534
535 def test_suite():
536 suite = LayeredDocFileSuite(
537+ [],
538 layer=BaseLayer)
539 suite.addTest(doctest.DocTestSuite(
540 testing, optionflags=NORMALIZE_WHITESPACE|ELLIPSIS))
541 return suite
542-
543
544=== modified file 'lib/lp/testing/tests/test_systemdocs.py'
545--- lib/lp/testing/tests/test_systemdocs.py 2011-12-29 05:29:36 +0000
546+++ lib/lp/testing/tests/test_systemdocs.py 2012-06-13 20:57:19 +0000
547@@ -55,8 +55,8 @@
548 self.makeTestFile('bar.txt')
549 base = os.path.basename(self.tempdir)
550 suite = LayeredDocFileSuite(
551- os.path.join(base, 'foo.txt'),
552- os.path.join(base, 'bar.txt'))
553+ [os.path.join(base, 'foo.txt'),
554+ os.path.join(base, 'bar.txt')])
555 self.assertTrue(isinstance(suite, unittest.TestSuite))
556
557 [foo_test, bar_test] = list(suite)
558
559=== modified file 'versions.cfg'
560--- versions.cfg 2012-06-13 18:59:09 +0000
561+++ versions.cfg 2012-06-13 20:57:19 +0000
562@@ -299,11 +299,15 @@
563 # p7 was unused
564 # p8 redirects stdout and stderr to a black hole device when --subunit is used
565 # p9 adds the redirection of __stderr__ to a black hole device
566+# p10 changed the test reporting to use test.id() rather than
567+# str(test) since only the id is unique.
568+# p11 reverts p9.
569+# p12 reverts p11, restoring p9.
570 # To build (use Python 2.6) run "python bootstrap.py; ./bin/buildout". Then to
571 # build the distribution run "bin/buildout setup . sdist"
572 # Make sure you have subunit installed. When running tests, be aware that
573 # three will fail initially, per http://pastebin.ubuntu.com/913757/.
574-zope.testing = 3.9.4-p10
575+zope.testing = 3.9.4-p12
576 zope.thread = 3.4
577 zope.traversing = 3.8.0
578 zope.viewlet = 3.6.1