Merge ~cjwatson/launchpad:buildmaster-more-future-imports into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 148a5b7861d3a4b928b1cfed40bf41305e1d18a0
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:buildmaster-more-future-imports
Merge into: launchpad:master
Diff against target: 493 lines (+75/-73)
4 files modified
lib/lp/buildmaster/stories/builder-views.txt (+31/-31)
lib/lp/buildmaster/stories/xx-builder-page.txt (+22/-22)
lib/lp/buildmaster/stories/xx-buildfarm-index.txt (+17/-17)
lib/lp/buildmaster/tests/test_doc.py (+5/-3)
Reviewer Review Type Date Requested Status
Ioana Lasc (community) Approve
Review via email: mp+395340@code.launchpad.net

Commit message

Convert remaining lp.buildmaster tests to preferred __future__ imports

Description of the change

I missed a few of these in 91b5e52567627cd13f7030b42c189c72d657e762, notably the pagetests.

To post a comment you must log in.
Revision history for this message
Ioana Lasc (ilasc) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/buildmaster/stories/builder-views.txt b/lib/lp/buildmaster/stories/builder-views.txt
2index 5637eb7..f93d409 100644
3--- a/lib/lp/buildmaster/stories/builder-views.txt
4+++ b/lib/lp/buildmaster/stories/builder-views.txt
5@@ -18,13 +18,13 @@ Let's instantiate the view for +index:
6
7 >>> builder_view = getMultiAdapter((builder, request), name="+index")
8
9- >>> print builder_view.page_title
10+ >>> print(builder_view.page_title)
11 Builder ...Bob The Builder...
12
13 The BuilderView provides a helper for the text to use on the toggle
14 mode button.
15
16- >>> print builder_view.toggle_mode_text
17+ >>> print(builder_view.toggle_mode_text)
18 Switch to manual-mode
19
20
21@@ -33,7 +33,7 @@ mode button.
22 Let's instantiate a view for +history:
23
24 >>> builder_view = getMultiAdapter((builder, request), name="+history")
25- >>> print builder_view.page_title
26+ >>> print(builder_view.page_title)
27 Build history
28
29 setupBuildList, build a batched list of build records and store it
30@@ -60,11 +60,11 @@ by mark. we nee to log in as mark or any other member of admin team
31 >>> from lp.testing.views import create_initialized_view
32 >>> login("foo.bar@canonical.com")
33 >>> builder_view = create_initialized_view(builder, name="+edit")
34- >>> print builder_view.page_title
35+ >>> print(builder_view.page_title)
36 Change details for builder ...Bob The Builder...
37
38 >>> for field_name in builder_view.field_names:
39- ... print field_name
40+ ... print(field_name)
41 name
42 title
43 processors
44@@ -79,24 +79,24 @@ by mark. we nee to log in as mark or any other member of admin team
45 active
46
47 >>> for action in builder_view.actions:
48- ... print action.label
49+ ... print(action.label)
50 Change
51
52 The BuilderEditView also has a next_url property for redirecting after
53 a successful form submission.
54
55- >>> print builder_view.next_url
56+ >>> print(builder_view.next_url)
57 http://launchpad.test/builders/bob
58
59 The BuilderEditView can be used to update the relevant fields on the
60 builder.
61
62 >>> def print_builder_info(builder):
63- ... print "%s: manual=%s, vm_host=%s." % (
64+ ... print("%s: manual=%s, vm_host=%s." % (
65 ... builder.name,
66 ... builder.manual,
67 ... builder.vm_host,
68- ... )
69+ ... ))
70 >>> print_builder_info(builder)
71 bob: manual=False, vm_host=None.
72
73@@ -114,7 +114,7 @@ builder.
74 After editing a builder, a relevant notification is added to the view.
75
76 >>> for notification in builder_view.request.notifications:
77- ... print notification.message
78+ ... print(notification.message)
79 The builder "Bob The Builder" was updated successfully.
80
81
82@@ -174,15 +174,15 @@ is widely available:
83 * Frog 'currentjob' exists;
84 * Frog has no 'failnotes';
85
86- >>> print frog.builderok
87+ >>> print(frog.builderok)
88 True
89
90 >>> build_set = getUtility(IBinaryPackageBuildSet)
91 >>> build = build_set.getByQueueEntry(frog.currentjob)
92- >>> print build.title
93+ >>> print(build.title)
94 i386 build of privacy-test 666 in ubuntutest breezy-autotest RELEASE
95
96- >>> print frog.failnotes
97+ >>> print(frog.failnotes)
98 None
99
100 Accessing the view for $builder/+index as a Foo Bar, which has
101@@ -196,14 +196,14 @@ all the 'private' information is exposed.
102 >>> empty_request = LaunchpadTestRequest(form={})
103 >>> admin_view = getMultiAdapter((frog, empty_request), name="+index")
104
105- >>> print admin_view.context.builderok
106+ >>> print(admin_view.context.builderok)
107 True
108
109 >>> build = build_set.getByQueueEntry(admin_view.context.currentjob)
110- >>> print build.title
111+ >>> print(build.title)
112 i386 build of privacy-test 666 in ubuntutest breezy-autotest RELEASE
113
114- >>> print admin_view.context.failnotes
115+ >>> print(admin_view.context.failnotes)
116 None
117
118 >>> import datetime
119@@ -211,7 +211,7 @@ all the 'private' information is exposed.
120 >>> from zope.security.proxy import removeSecurityProxy
121 >>> removeSecurityProxy(private_job).date_started = (
122 ... datetime.datetime.now(pytz.UTC) - datetime.timedelta(10))
123- >>> print admin_view.current_build_duration
124+ >>> print(admin_view.current_build_duration)
125 10 days...
126
127 Once the private job is gone, Frog 'real' details are exposed publicly
128@@ -292,16 +292,16 @@ contains the following attributes:
129
130 >>> builder_category = builderset_view.nonvirt_builders
131
132- >>> print builder_category
133+ >>> print(builder_category)
134 <...BuilderCategory ...>
135
136- >>> print builder_category.title
137+ >>> print(builder_category.title)
138 Non-virtual build status
139
140- >>> print builder_category.virtualized
141+ >>> print(builder_category.virtualized)
142 False
143
144- >>> print builder_category.groups[0]
145+ >>> print(builder_category.groups[0])
146 <...BuilderGroup ...>
147
148 Similarly to what is done in the UI, we have a helper that prints the
149@@ -309,10 +309,10 @@ grouped builders within a category in a easy manner.
150
151 >>> def print_category(category):
152 ... for group in category.groups:
153- ... print group.processor_name, \
154- ... group.number_of_available_builders, \
155- ... group.queue_size, \
156- ... group.duration
157+ ... print(group.processor_name,
158+ ... group.number_of_available_builders,
159+ ... group.queue_size,
160+ ... group.duration)
161
162 >>> print_category(builder_category)
163 386 2 1 0:00:30
164@@ -334,16 +334,16 @@ Each `BuilderGroup` contains the following attributes:
165
166 >>> [i386_group, amd64_group, hppa_group] = builder_category.groups
167
168- >>> print i386_group.processor_name
169+ >>> print(i386_group.processor_name)
170 386
171
172- >>> print i386_group.number_of_available_builders
173+ >>> print(i386_group.number_of_available_builders)
174 2
175
176- >>> print i386_group.queue_size
177+ >>> print(i386_group.queue_size)
178 1
179
180- >>> print i386_group.duration
181+ >>> print(i386_group.duration)
182 0:00:30
183
184 The 'virtual' builder category is also available in BuilderSetView as a
185@@ -351,10 +351,10 @@ The 'virtual' builder category is also available in BuilderSetView as a
186
187 >>> builder_category = builderset_view.virt_builders
188
189- >>> print builder_category.title
190+ >>> print(builder_category.title)
191 Virtual build status
192
193- >>> print builder_category.virtualized
194+ >>> print(builder_category.virtualized)
195 True
196
197 >>> print_category(builder_category)
198diff --git a/lib/lp/buildmaster/stories/xx-builder-page.txt b/lib/lp/buildmaster/stories/xx-builder-page.txt
199index c27de04..36d4c33 100644
200--- a/lib/lp/buildmaster/stories/xx-builder-page.txt
201+++ b/lib/lp/buildmaster/stories/xx-builder-page.txt
202@@ -16,15 +16,15 @@ builder state. In the sampledata, the builder 'bob' is building
203 >>> anon_browser.open("http://launchpad.test/builders")
204 >>> anon_browser.getLink("bob").click()
205
206- >>> print extract_text(find_main_content(anon_browser.contents))
207+ >>> print(extract_text(find_main_content(anon_browser.contents)))
208 Bob The Builder
209 ...
210 Bob The Builder builds 386 binaries and is owned by Launchpad Buildd
211 Admins.
212 ...
213
214- >>> print extract_text(find_portlet(
215- ... anon_browser.contents, 'View full history Current status'))
216+ >>> print(extract_text(find_portlet(
217+ ... anon_browser.contents, 'View full history Current status')))
218 View full history Current status
219 Building i386 build of mozilla-firefox 0.9 in ubuntu hoary RELEASE
220 Started ... ago.
221@@ -37,8 +37,8 @@ timezone. This way they can easily find out if they are reading
222 outdated information.
223
224 >>> user_browser.open(anon_browser.url)
225- >>> print extract_text(find_portlet(
226- ... user_browser.contents, 'View full history Current status'))
227+ >>> print(extract_text(find_portlet(
228+ ... user_browser.contents, 'View full history Current status')))
229 View full history Current status
230 Building i386 build of mozilla-firefox 0.9 in ubuntu hoary RELEASE
231 Started ... ago.
232@@ -50,8 +50,8 @@ The anonymous user can see the builder details portlet and it contains
233 information about the builder itself, like name, architecture and
234 location.
235
236- >>> print extract_text(
237- ... find_portlet(anon_browser.contents, 'Builder information'))
238+ >>> print(extract_text(
239+ ... find_portlet(anon_browser.contents, 'Builder information')))
240 Builder information
241 Architectures: 386
242 Location: http://localhost:8221/
243@@ -73,22 +73,22 @@ Idle builders show more details of their status.
244 ... builder = factory.makeBuilder(name='victim')
245 ... builder.setCleanStatus(BuilderCleanStatus.DIRTY)
246 >>> anon_browser.open('http://launchpad.test/builders/victim')
247- >>> print extract_text(find_portlet(
248- ... anon_browser.contents, 'View full history Current status'))
249+ >>> print(extract_text(find_portlet(
250+ ... anon_browser.contents, 'View full history Current status')))
251 View full history Current status
252 Cleaning
253 >>> with admin_logged_in():
254 ... builder.setCleanStatus(BuilderCleanStatus.CLEANING)
255 >>> anon_browser.open(anon_browser.url)
256- >>> print extract_text(find_portlet(
257- ... anon_browser.contents, 'View full history Current status'))
258+ >>> print(extract_text(find_portlet(
259+ ... anon_browser.contents, 'View full history Current status')))
260 View full history Current status
261 Cleaning
262 >>> with admin_logged_in():
263 ... builder.setCleanStatus(BuilderCleanStatus.CLEAN)
264 >>> anon_browser.open(anon_browser.url)
265- >>> print extract_text(find_portlet(
266- ... anon_browser.contents, 'View full history Current status'))
267+ >>> print(extract_text(find_portlet(
268+ ... anon_browser.contents, 'View full history Current status')))
269 View full history Current status
270 Idle
271
272@@ -149,7 +149,7 @@ effect immediately.
273
274 # We use backslashreplace because the page title includes smart quotes.
275 >>> from lp.services.helpers import backslashreplace
276- >>> print backslashreplace(cprov_browser.title)
277+ >>> print(backslashreplace(cprov_browser.title))
278 Change details for...
279
280 >>> title = cprov_browser.getControl(name="field.title")
281@@ -161,7 +161,7 @@ effect immediately.
282
283 # Submitting the change details form redirects to the index page
284 # for the builder.
285- >>> print backslashreplace(cprov_browser.title)
286+ >>> print(backslashreplace(cprov_browser.title))
287 Donkey builder : Build Farm
288
289 Then restores it once he realises his mistake.
290@@ -176,7 +176,7 @@ automatic (AUTO) mode.
291
292 >>> details_portlet = find_portlet(
293 ... cprov_browser.contents, "Builder information")
294- >>> print str(extract_text(details_portlet))
295+ >>> print(str(extract_text(details_portlet)))
296 Builder information
297 Architectures: amd64 hppa
298 Location: http://localhost:8221/
299@@ -193,7 +193,7 @@ He can see now, in the details portlet that the builder is in manual-mode.
300
301 >>> details_portlet = find_portlet(
302 ... cprov_browser.contents, "Builder information")
303- >>> print str(extract_text(details_portlet))
304+ >>> print(str(extract_text(details_portlet)))
305 Builder information
306 ...
307 Mode: This builder is in manual-mode and not accepting jobs from the
308@@ -234,7 +234,7 @@ transient failures or is used for another purpose.
309
310 >>> cprov_browser.open('http://launchpad.test/builders')
311 >>> cprov_browser.getLink('bob').click()
312- >>> print backslashreplace(cprov_browser.title)
313+ >>> print(backslashreplace(cprov_browser.title))
314 Bob The Builder : Build Farm
315
316 Celso can toggle the active bit using the Change details form.
317@@ -252,7 +252,7 @@ Farm list. Celso cannot see the link to it.
318
319 >>> cprov_browser.getLink("Build Farm").click()
320
321- >>> print extract_text(find_main_content(cprov_browser.contents))
322+ >>> print(extract_text(find_main_content(cprov_browser.contents)))
323 The Launchpad build farm
324 Register a new build machine
325 1 available build machine, 1 disabled and 0 building of a total
326@@ -273,7 +273,7 @@ Farm list. Celso cannot see the link to it.
327 But Celso can access the deactivated builder via its URL.
328
329 >>> cprov_browser.open('http://launchpad.test/+builds/bob')
330- >>> print backslashreplace(cprov_browser.title)
331+ >>> print(backslashreplace(cprov_browser.title))
332 Bob The Builder : Build Farm
333
334
335@@ -292,7 +292,7 @@ Nor is the toggle mode control included on the index page.
336
337 >>> user_browser.getControl(name="field.actions.update")
338 Traceback (most recent call last):
339- LookupError: name 'field.actions.update'
340+ LookupError: name ...'field.actions.update'
341 ...
342
343 Nor can they access the edit page directly via URL.
344@@ -311,7 +311,7 @@ The same is true for the anonymous user:
345
346 >>> anon_browser.getControl(name="field.actions.update")
347 Traceback (most recent call last):
348- LookupError: name 'field.actions.update'
349+ LookupError: name ...'field.actions.update'
350 ...
351
352 >>> anon_browser.open("http://localhost/+builds/bob/+edit")
353diff --git a/lib/lp/buildmaster/stories/xx-buildfarm-index.txt b/lib/lp/buildmaster/stories/xx-buildfarm-index.txt
354index 4ceebda..5fd0cf5 100644
355--- a/lib/lp/buildmaster/stories/xx-buildfarm-index.txt
356+++ b/lib/lp/buildmaster/stories/xx-buildfarm-index.txt
357@@ -12,7 +12,7 @@ finally by name. A short textual description of their status is listed
358 in the 'Status' column. There are also 2 portlets on the right-side
359 containing the build queue status summary for each build domain.
360
361- >>> print extract_text(find_main_content(anon_browser.contents))
362+ >>> print(extract_text(find_main_content(anon_browser.contents)))
363 The Launchpad build farm
364 1 available build machine, 1 disabled and 1 building of a total of
365 2 registered.
366@@ -30,8 +30,8 @@ containing the build queue status summary for each build domain.
367 When building, the 'Status' column contains a link to the
368 corresponding 'Build' page.
369
370- >>> print anon_browser.getLink(
371- ... 'i386 build of mozilla-firefox 0.9').url
372+ >>> print(anon_browser.getLink(
373+ ... 'i386 build of mozilla-firefox 0.9').url)
374 http://launchpad.test/ubuntu/+source/mozilla-firefox/0.9/+build/8
375
376 The build status portlets contain the number of builds waiting
377@@ -40,14 +40,14 @@ supported processor on each separated build domain, 'nonvirt'
378 (PRIMARY and PARTNER) and 'virt'.
379
380 >>> anon_browser.reload()
381- >>> print extract_text(
382- ... find_tag_by_id(anon_browser.contents, 'nonvirt-queue-status'))
383+ >>> print(extract_text(
384+ ... find_tag_by_id(anon_browser.contents, 'nonvirt-queue-status')))
385 Non-virtual build status
386 Architecture Builders Queue
387 386 1 1 job (1 minute)
388
389- >>> print extract_text(
390- ... find_tag_by_id(anon_browser.contents, 'virt-queue-status',))
391+ >>> print(extract_text(
392+ ... find_tag_by_id(anon_browser.contents, 'virt-queue-status')))
393 Virtual build status
394 Architecture Builders Queue
395 386 0 empty
396@@ -73,8 +73,8 @@ the corresponding portlet with their estimated duration as well.
397 >>> logout()
398
399 >>> anon_browser.reload()
400- >>> print extract_text(
401- ... find_tag_by_id(anon_browser.contents, 'virt-queue-status'))
402+ >>> print(extract_text(
403+ ... find_tag_by_id(anon_browser.contents, 'virt-queue-status')))
404 Virtual build status
405 Architecture Builders Queue
406 386 0 1 job (1 minute)
407@@ -89,14 +89,14 @@ record already exists, we must manually set it to non-virtualized too.
408 >>> logout()
409
410 >>> anon_browser.reload()
411- >>> print extract_text(
412- ... find_tag_by_id(anon_browser.contents, 'virt-queue-status'))
413+ >>> print(extract_text(
414+ ... find_tag_by_id(anon_browser.contents, 'virt-queue-status')))
415 Virtual build status
416 Architecture Builders Queue
417 386 0 empty
418
419- >>> print extract_text(
420- ... find_tag_by_id(anon_browser.contents, 'nonvirt-queue-status'))
421+ >>> print(extract_text(
422+ ... find_tag_by_id(anon_browser.contents, 'nonvirt-queue-status')))
423 Non-virtual build status
424 Architecture Builders Queue
425 386 1 2 jobs (2 minutes)
426@@ -124,7 +124,7 @@ Administrators can create new builders.
427
428 >>> admin_browser.getLink("Register a new build machine").click()
429
430- >>> print admin_browser.title
431+ >>> print(admin_browser.title)
432 Register a new...
433
434 Registering a new builder involves setting its name, title and corresponding
435@@ -148,14 +148,14 @@ to the builder.
436 By default, builders are created as 'Publicly Visible', although the
437 administrator can change this value during creation time.
438
439- >>> print admin_browser.getControl('Publicly Visible').selected
440+ >>> print(admin_browser.getControl('Publicly Visible').selected)
441 True
442 >>> admin_browser.getControl('Publicly Visible').selected = False
443
444 Builder as created as 'non-virtual' by default, but the administrator
445 can also modify that while creating a builder.
446
447- >>> print admin_browser.getControl('Virtualized').selected
448+ >>> print(admin_browser.getControl('Virtualized').selected)
449 False
450 >>> admin_browser.getControl('VM host').value
451 ''
452@@ -172,7 +172,7 @@ just-created builder page.
453
454 >>> from lp.services.helpers import backslashreplace
455 >>> admin_browser.getControl("Register builder").click()
456- >>> print backslashreplace(admin_browser.title)
457+ >>> print(backslashreplace(admin_browser.title))
458 Tubaina : Build Farm
459 >>> 'amd64 and hppa' in admin_browser.contents
460 True
461diff --git a/lib/lp/buildmaster/tests/test_doc.py b/lib/lp/buildmaster/tests/test_doc.py
462index 0a1cfd6..15cebaa 100644
463--- a/lib/lp/buildmaster/tests/test_doc.py
464+++ b/lib/lp/buildmaster/tests/test_doc.py
465@@ -19,6 +19,7 @@ from lp.testing.layers import (
466 LaunchpadFunctionalLayer,
467 LaunchpadZopelessLayer,
468 )
469+from lp.testing.pages import setUpGlobs
470 from lp.testing.systemdocs import (
471 LayeredDocFileSuite,
472 setGlobs,
473@@ -50,11 +51,11 @@ def buildmasterTearDown(test):
474 special = {
475 'builder.txt': LayeredDocFileSuite(
476 '../doc/builder.txt',
477- setUp=setUp, tearDown=tearDown,
478+ setUp=lambda test: setUp(test, future=True), tearDown=tearDown,
479 layer=LaunchpadFunctionalLayer),
480 'buildqueue.txt': LayeredDocFileSuite(
481 '../doc/buildqueue.txt',
482- setUp=setUp, tearDown=tearDown,
483+ setUp=lambda test: setUp(test, future=True), tearDown=tearDown,
484 layer=LaunchpadFunctionalLayer),
485 }
486
487@@ -62,4 +63,5 @@ special = {
488 def test_suite():
489 return build_test_suite(
490 here, special, layer=LaunchpadZopelessLayer,
491- setUp=lambda test: setUp(test, future=True))
492+ setUp=lambda test: setUp(test, future=True),
493+ pageTestsSetUp=lambda test: setUpGlobs(test, future=True))

Subscribers

People subscribed via source and target branches

to status/vote changes: