Merge lp:~cjwatson/launchpad/buildmaster-tests-future-imports into lp:launchpad

Proposed by Colin Watson
Status: Merged
Merged at revision: 18687
Proposed branch: lp:~cjwatson/launchpad/buildmaster-tests-future-imports
Merge into: lp:launchpad
Diff against target: 491 lines (+86/-50)
20 files modified
lib/lp/buildmaster/browser/tests/test_builder.py (+3/-1)
lib/lp/buildmaster/browser/tests/test_builder_views.py (+2/-0)
lib/lp/buildmaster/browser/tests/test_processor.py (+3/-1)
lib/lp/buildmaster/doc/builder.txt (+11/-11)
lib/lp/buildmaster/doc/buildfarmjobbehaviour.txt (+1/-1)
lib/lp/buildmaster/doc/buildqueue.txt (+17/-17)
lib/lp/buildmaster/tests/harness.py (+3/-1)
lib/lp/buildmaster/tests/mock_slaves.py (+2/-0)
lib/lp/buildmaster/tests/test_builder.py (+2/-0)
lib/lp/buildmaster/tests/test_buildfarmjob.py (+3/-1)
lib/lp/buildmaster/tests/test_buildfarmjobbehaviour.py (+3/-1)
lib/lp/buildmaster/tests/test_buildmaster_documentation.py (+3/-1)
lib/lp/buildmaster/tests/test_buildqueue.py (+6/-4)
lib/lp/buildmaster/tests/test_doc.py (+6/-2)
lib/lp/buildmaster/tests/test_interactor.py (+4/-2)
lib/lp/buildmaster/tests/test_manager.py (+5/-3)
lib/lp/buildmaster/tests/test_packagebuild.py (+3/-1)
lib/lp/buildmaster/tests/test_processor.py (+3/-1)
lib/lp/buildmaster/tests/test_queuedepth.py (+3/-1)
lib/lp/buildmaster/tests/test_webservice.py (+3/-1)
To merge this branch: bzr merge lp:~cjwatson/launchpad/buildmaster-tests-future-imports
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+347519@code.launchpad.net

Commit message

Convert tests under lp.buildmaster to Launchpad's preferred __future__ imports.

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) wrote :

Self-approving: test-only and mostly mechanical.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/buildmaster/browser/tests/test_builder.py'
2--- lib/lp/buildmaster/browser/tests/test_builder.py 2017-12-21 20:39:39 +0000
3+++ lib/lp/buildmaster/browser/tests/test_builder.py 2018-06-06 11:29:12 +0000
4@@ -1,8 +1,10 @@
5-# Copyright 2010-2013 Canonical Ltd. This software is licensed under the
6+# Copyright 2010-2018 Canonical Ltd. This software is licensed under the
7 # GNU Affero General Public License version 3 (see the file LICENSE).
8
9 """Tests for the lp.soyuz.browser.builder module."""
10
11+from __future__ import absolute_import, print_function, unicode_literals
12+
13 __metaclass__ = type
14
15 from zope.component import getUtility
16
17=== modified file 'lib/lp/buildmaster/browser/tests/test_builder_views.py'
18--- lib/lp/buildmaster/browser/tests/test_builder_views.py 2018-02-02 10:06:24 +0000
19+++ lib/lp/buildmaster/browser/tests/test_builder_views.py 2018-06-06 11:29:12 +0000
20@@ -1,6 +1,8 @@
21 # Copyright 2009-2018 Canonical Ltd. This software is licensed under the
22 # GNU Affero General Public License version 3 (see the file LICENSE).
23
24+from __future__ import absolute_import, print_function, unicode_literals
25+
26 __metaclass__ = type
27
28 from functools import partial
29
30=== modified file 'lib/lp/buildmaster/browser/tests/test_processor.py'
31--- lib/lp/buildmaster/browser/tests/test_processor.py 2018-01-02 16:10:26 +0000
32+++ lib/lp/buildmaster/browser/tests/test_processor.py 2018-06-06 11:29:12 +0000
33@@ -1,8 +1,10 @@
34-# Copyright 2011 Canonical Ltd. This software is licensed under the
35+# Copyright 2011-2018 Canonical Ltd. This software is licensed under the
36 # GNU Affero General Public License version 3 (see the file LICENSE).
37
38 """Tests for process navigation."""
39
40+from __future__ import absolute_import, print_function, unicode_literals
41+
42 __metaclass__ = type
43
44 from lp.services.webapp.publisher import canonical_url
45
46=== modified file 'lib/lp/buildmaster/doc/builder.txt'
47--- lib/lp/buildmaster/doc/builder.txt 2014-04-23 10:50:06 +0000
48+++ lib/lp/buildmaster/doc/builder.txt 2018-06-06 11:29:12 +0000
49@@ -20,11 +20,11 @@
50
51 >>> from lp.testing import verifyObject
52
53- >>> print builder.name
54+ >>> print(builder.name)
55 bob
56- >>> print builder.builderok
57+ >>> print(builder.builderok)
58 True
59- >>> print builder.failnotes
60+ >>> print(builder.failnotes)
61 None
62
63
64@@ -42,7 +42,7 @@
65 Iterating over a BuilderSet yields all registered builders.
66
67 >>> for b in builderset:
68- ... print b.name
69+ ... print(b.name)
70 bob
71 frog
72
73@@ -53,16 +53,16 @@
74
75 Builders can be retrieved by name.
76
77- >>> print builderset['bob'].name
78+ >>> print(builderset['bob'].name)
79 bob
80- >>> print builderset['bad']
81+ >>> print(builderset['bad'])
82 None
83
84 And also by ID.
85
86- >>> print builderset.get(2).name
87+ >>> print(builderset.get(2).name)
88 frog
89- >>> print builderset.get(100).name
90+ >>> print(builderset.get(100).name)
91 Traceback (most recent call last):
92 ...
93 SQLObjectNotFound: Object not found
94@@ -80,7 +80,7 @@
95 virtualization status, architecture, then name.
96
97 >>> for b in builderset.getBuilders():
98- ... print b.name
99+ ... print(b.name)
100 bob
101 dummy
102 frog
103@@ -88,7 +88,7 @@
104 >>> bnew.active = False
105 >>> login(ANONYMOUS)
106 >>> for b in builderset.getBuilders():
107- ... print b.name
108+ ... print(b.name)
109 bob
110 frog
111
112@@ -149,5 +149,5 @@
113 ... distroseries=ubuntu.currentseries).queueBuild()
114 >>> transaction.commit()
115 >>> queue_sizes = builderset.getBuildQueueSizes()
116- >>> print queue_sizes['virt']['386']
117+ >>> print(queue_sizes['virt']['386'])
118 (1L, datetime.timedelta(0, 600))
119
120=== modified file 'lib/lp/buildmaster/doc/buildfarmjobbehaviour.txt'
121--- lib/lp/buildmaster/doc/buildfarmjobbehaviour.txt 2015-07-08 16:05:11 +0000
122+++ lib/lp/buildmaster/doc/buildfarmjobbehaviour.txt 2018-06-06 11:29:12 +0000
123@@ -32,7 +32,7 @@
124 ... """A custom build behaviour for building blah."""
125 ...
126 ... def dispatchBuildToSlave(self, logger):
127- ... print "Did something special to dispatch MySpecialBuild."
128+ ... print("Did something special to dispatch MySpecialBuild.")
129
130 For this documentation, we'll also need a dummy new build farm job.
131
132
133=== modified file 'lib/lp/buildmaster/doc/buildqueue.txt'
134--- lib/lp/buildmaster/doc/buildqueue.txt 2013-11-19 09:27:01 +0000
135+++ lib/lp/buildmaster/doc/buildqueue.txt 2018-06-06 11:29:12 +0000
136@@ -100,16 +100,16 @@
137 >>> bob = getUtility(IBuilderSet)['bob']
138 >>> job = bob.currentjob
139
140- >>> print job.builder.name
141+ >>> print(job.builder.name)
142 bob
143 >>> job.date_started is not None
144 True
145- >>> print job.logtail
146+ >>> print(job.logtail)
147 Dummy sampledata entry, not processing
148 >>> build = getUtility(IBinaryPackageBuildSet).getByQueueEntry(job)
149- >>> print build.status.name
150+ >>> print(build.status.name)
151 BUILDING
152- >>> print job.lastscore
153+ >>> print(job.lastscore)
154 1
155
156 IBuildQueue.reset() will reset the job, enabling it to be dispatched
157@@ -118,20 +118,20 @@
158 >>> job.reset()
159
160 >>> del get_property_cache(bob).currentjob
161- >>> print bob.currentjob
162+ >>> print(bob.currentjob)
163 None
164
165- >>> print job.status.name
166+ >>> print(job.status.name)
167 WAITING
168- >>> print job.builder
169- None
170- >>> print job.date_started
171- None
172- >>> print job.logtail
173- None
174- >>> print build.status.name
175+ >>> print(job.builder)
176+ None
177+ >>> print(job.date_started)
178+ None
179+ >>> print(job.logtail)
180+ None
181+ >>> print(build.status.name)
182 NEEDSBUILD
183- >>> print job.lastscore
184+ >>> print(job.lastscore)
185 1
186
187 On the flip-side, IBuildQueue.markAsBuilding() will assign the job to
188@@ -143,11 +143,11 @@
189 >>> bob.currentjob == job
190 True
191
192- >>> print job.builder.name
193+ >>> print(job.builder.name)
194 bob
195 >>> job.date_started is not None
196 True
197- >>> print build.status.name
198+ >>> print(build.status.name)
199 BUILDING
200
201
202@@ -171,5 +171,5 @@
203 applications:
204
205 >>> current_job = bqset.getByBuilder(bob)
206- >>> print current_job.builder.name
207+ >>> print(current_job.builder.name)
208 bob
209
210=== modified file 'lib/lp/buildmaster/tests/harness.py'
211--- lib/lp/buildmaster/tests/harness.py 2012-02-28 05:36:01 +0000
212+++ lib/lp/buildmaster/tests/harness.py 2018-06-06 11:29:12 +0000
213@@ -1,8 +1,10 @@
214-# Copyright 2009 Canonical Ltd. This software is licensed under the
215+# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
216 # GNU Affero General Public License version 3 (see the file LICENSE).
217
218 """TacHandler for `buildd-manager` daemon."""
219
220+from __future__ import absolute_import, print_function, unicode_literals
221+
222 __metaclass__ = type
223
224 __all__ = [
225
226=== modified file 'lib/lp/buildmaster/tests/mock_slaves.py'
227--- lib/lp/buildmaster/tests/mock_slaves.py 2018-05-14 08:15:12 +0000
228+++ lib/lp/buildmaster/tests/mock_slaves.py 2018-06-06 11:29:12 +0000
229@@ -3,6 +3,8 @@
230
231 """Mock Build objects for tests soyuz buildd-system."""
232
233+from __future__ import absolute_import, print_function, unicode_literals
234+
235 __metaclass__ = type
236
237 __all__ = [
238
239=== modified file 'lib/lp/buildmaster/tests/test_builder.py'
240--- lib/lp/buildmaster/tests/test_builder.py 2018-01-10 10:45:24 +0000
241+++ lib/lp/buildmaster/tests/test_builder.py 2018-06-06 11:29:12 +0000
242@@ -3,6 +3,8 @@
243
244 """Test Builder features."""
245
246+from __future__ import absolute_import, print_function, unicode_literals
247+
248 from fixtures import FakeLogger
249 from zope.component import getUtility
250 from zope.security.proxy import removeSecurityProxy
251
252=== modified file 'lib/lp/buildmaster/tests/test_buildfarmjob.py'
253--- lib/lp/buildmaster/tests/test_buildfarmjob.py 2018-01-02 10:54:31 +0000
254+++ lib/lp/buildmaster/tests/test_buildfarmjob.py 2018-06-06 11:29:12 +0000
255@@ -1,8 +1,10 @@
256-# Copyright 2010-2013 Canonical Ltd. This software is licensed under the
257+# Copyright 2010-2018 Canonical Ltd. This software is licensed under the
258 # GNU Affero General Public License version 3 (see the file LICENSE).
259
260 """Tests for `IBuildFarmJob`."""
261
262+from __future__ import absolute_import, print_function, unicode_literals
263+
264 __metaclass__ = type
265
266 from datetime import (
267
268=== modified file 'lib/lp/buildmaster/tests/test_buildfarmjobbehaviour.py'
269--- lib/lp/buildmaster/tests/test_buildfarmjobbehaviour.py 2018-05-02 13:22:17 +0000
270+++ lib/lp/buildmaster/tests/test_buildfarmjobbehaviour.py 2018-06-06 11:29:12 +0000
271@@ -1,8 +1,10 @@
272-# Copyright 2010-2014 Canonical Ltd. This software is licensed under the
273+# Copyright 2010-2018 Canonical Ltd. This software is licensed under the
274 # GNU Affero General Public License version 3 (see the file LICENSE).
275
276 """Unit tests for BuildFarmJobBehaviourBase."""
277
278+from __future__ import absolute_import, print_function, unicode_literals
279+
280 __metaclass__ = type
281
282 from datetime import datetime
283
284=== modified file 'lib/lp/buildmaster/tests/test_buildmaster_documentation.py'
285--- lib/lp/buildmaster/tests/test_buildmaster_documentation.py 2012-01-20 16:11:11 +0000
286+++ lib/lp/buildmaster/tests/test_buildmaster_documentation.py 2018-06-06 11:29:12 +0000
287@@ -1,8 +1,10 @@
288-# Copyright 2009 Canonical Ltd. This software is licensed under the
289+# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
290 # GNU Affero General Public License version 3 (see the file LICENSE).
291
292 """Runs the doctests for buildmaster module."""
293
294+from __future__ import absolute_import, print_function, unicode_literals
295+
296 __metaclass__ = type
297
298
299
300=== modified file 'lib/lp/buildmaster/tests/test_buildqueue.py'
301--- lib/lp/buildmaster/tests/test_buildqueue.py 2015-05-14 08:50:41 +0000
302+++ lib/lp/buildmaster/tests/test_buildqueue.py 2018-06-06 11:29:12 +0000
303@@ -1,7 +1,9 @@
304-# Copyright 2009-2014 Canonical Ltd. This software is licensed under the
305+# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
306 # GNU Affero General Public License version 3 (see the file LICENSE).
307 """Test BuildQueue features."""
308
309+from __future__ import absolute_import, print_function, unicode_literals
310+
311 from datetime import timedelta
312
313 from storm.sqlobject import SQLObjectNotFound
314@@ -54,7 +56,7 @@
315 def processor_name(bq):
316 return ('None' if bq.processor is None else bq.processor.name)
317
318- print ""
319+ print("")
320 queue_entries = [build.buildqueue_record for build in builds]
321 queue_entries = sorted(
322 queue_entries, key=lambda qe: qe.job.id, reverse=True)
323@@ -65,10 +67,10 @@
324 source = getattr(queue_entry.specific_build, attr, None)
325 if source is not None:
326 break
327- print "%5s, %18s, p:%5s, v:%5s e:%s *** s:%5s" % (
328+ print("%5s, %18s, p:%5s, v:%5s e:%s *** s:%5s" % (
329 queue_entry.id, source.name, processor_name(queue_entry),
330 queue_entry.virtualized, queue_entry.estimated_duration,
331- queue_entry.lastscore)
332+ queue_entry.lastscore))
333
334
335 class TestBuildCancellation(TestCaseWithFactory):
336
337=== modified file 'lib/lp/buildmaster/tests/test_doc.py'
338--- lib/lp/buildmaster/tests/test_doc.py 2015-09-11 13:56:38 +0000
339+++ lib/lp/buildmaster/tests/test_doc.py 2018-06-06 11:29:12 +0000
340@@ -1,14 +1,18 @@
341-# Copyright 2015 Canonical Ltd. This software is licensed under the
342+# Copyright 2015-2018 Canonical Ltd. This software is licensed under the
343 # GNU Affero General Public License version 3 (see the file LICENSE).
344
345 """Run pagetests."""
346
347+from __future__ import absolute_import, print_function, unicode_literals
348+
349 import os
350
351 from lp.services.testing import build_test_suite
352+from lp.testing.systemdocs import setUp
353+
354
355 here = os.path.dirname(os.path.realpath(__file__))
356
357
358 def test_suite():
359- return build_test_suite(here)
360+ return build_test_suite(here, setUp=lambda test: setUp(test, future=True))
361
362=== modified file 'lib/lp/buildmaster/tests/test_interactor.py'
363--- lib/lp/buildmaster/tests/test_interactor.py 2017-12-19 17:22:44 +0000
364+++ lib/lp/buildmaster/tests/test_interactor.py 2018-06-06 11:29:12 +0000
365@@ -1,8 +1,10 @@
366-# Copyright 2009-2017 Canonical Ltd. This software is licensed under the
367+# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
368 # GNU Affero General Public License version 3 (see the file LICENSE).
369
370 """Test BuilderInteractor features."""
371
372+from __future__ import absolute_import, print_function, unicode_literals
373+
374 __all__ = [
375 'FakeBuildQueue',
376 'MockBuilderFactory',
377@@ -20,13 +22,13 @@
378 HasLength,
379 MatchesDict,
380 )
381+from testtools.testcase import ExpectedException
382 from testtools.twistedsupport import (
383 assert_fails_with,
384 AsynchronousDeferredRunTest,
385 AsynchronousDeferredRunTestForBrokenTwisted,
386 SynchronousDeferredRunTest,
387 )
388-from testtools.testcase import ExpectedException
389 from twisted.internet import (
390 defer,
391 reactor as default_reactor,
392
393=== modified file 'lib/lp/buildmaster/tests/test_manager.py'
394--- lib/lp/buildmaster/tests/test_manager.py 2017-12-19 17:22:44 +0000
395+++ lib/lp/buildmaster/tests/test_manager.py 2018-06-06 11:29:12 +0000
396@@ -2,11 +2,13 @@
397 # NOTE: The first line above must stay first; do not move the copyright
398 # notice to the top. See http://www.python.org/dev/peps/pep-0263/.
399 #
400-# Copyright 2009-2017 Canonical Ltd. This software is licensed under the
401+# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
402 # GNU Affero General Public License version 3 (see the file LICENSE).
403
404 """Tests for the renovated slave scanner aka BuilddManager."""
405
406+from __future__ import absolute_import, print_function, unicode_literals
407+
408 import os
409 import signal
410 import time
411@@ -902,7 +904,7 @@
412 with ExpectedException(
413 BuildDaemonIsolationError,
414 "Allegedly clean slave not idle "
415- "\('BuilderStatus.BUILDING' instead\)"):
416+ "\(u'BuilderStatus.BUILDING' instead\)"):
417 yield scanner.scan()
418 self.assertEqual(['status'], slave.call_log)
419
420@@ -1057,7 +1059,7 @@
421 slave = LostBuildingBrokenSlave()
422 self.builder.current_build.cancel()
423 with ExpectedException(
424- xmlrpclib.Fault, "<Fault 8002: 'Could not abort'>"):
425+ xmlrpclib.Fault, "<Fault 8002: u'Could not abort'>"):
426 yield self._getScanner().checkCancellation(self.vitals, slave)
427
428
429
430=== modified file 'lib/lp/buildmaster/tests/test_packagebuild.py'
431--- lib/lp/buildmaster/tests/test_packagebuild.py 2018-01-02 10:54:31 +0000
432+++ lib/lp/buildmaster/tests/test_packagebuild.py 2018-06-06 11:29:12 +0000
433@@ -1,8 +1,10 @@
434-# Copyright 2010-2013 Canonical Ltd. This software is licensed under the
435+# Copyright 2010-2018 Canonical Ltd. This software is licensed under the
436 # GNU Affero General Public License version 3 (see the file LICENSE).
437
438 """Tests for `IPackageBuild`."""
439
440+from __future__ import absolute_import, print_function, unicode_literals
441+
442 __metaclass__ = type
443
444 import hashlib
445
446=== modified file 'lib/lp/buildmaster/tests/test_processor.py'
447--- lib/lp/buildmaster/tests/test_processor.py 2018-01-02 16:10:26 +0000
448+++ lib/lp/buildmaster/tests/test_processor.py 2018-06-06 11:29:12 +0000
449@@ -1,8 +1,10 @@
450-# Copyright 2010 Canonical Ltd. This software is licensed under the
451+# Copyright 2010-2018 Canonical Ltd. This software is licensed under the
452 # GNU Affero General Public License version 3 (see the file LICENSE).
453
454 """Test Processor features."""
455
456+from __future__ import absolute_import, print_function, unicode_literals
457+
458 from zope.component import getUtility
459
460 from lp.buildmaster.interfaces.processor import (
461
462=== modified file 'lib/lp/buildmaster/tests/test_queuedepth.py'
463--- lib/lp/buildmaster/tests/test_queuedepth.py 2018-01-02 16:10:26 +0000
464+++ lib/lp/buildmaster/tests/test_queuedepth.py 2018-06-06 11:29:12 +0000
465@@ -1,7 +1,9 @@
466-# Copyright 2009-2013 Canonical Ltd. This software is licensed under the
467+# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
468 # GNU Affero General Public License version 3 (see the file LICENSE).
469 """Test BuildQueue start time estimation."""
470
471+from __future__ import absolute_import, print_function, unicode_literals
472+
473 from datetime import (
474 datetime,
475 timedelta,
476
477=== modified file 'lib/lp/buildmaster/tests/test_webservice.py'
478--- lib/lp/buildmaster/tests/test_webservice.py 2018-01-31 00:13:47 +0000
479+++ lib/lp/buildmaster/tests/test_webservice.py 2018-06-06 11:29:12 +0000
480@@ -1,8 +1,10 @@
481-# Copyright 2011-2014 Canonical Ltd. This software is licensed under the
482+# Copyright 2011-2018 Canonical Ltd. This software is licensed under the
483 # GNU Affero General Public License version 3 (see the file LICENSE).
484
485 """Tests for the builders webservice ."""
486
487+from __future__ import absolute_import, print_function, unicode_literals
488+
489 __metaclass__ = type
490
491 from json import dumps