launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #25864
[Merge] ~cjwatson/launchpad:buildmaster-more-future-imports into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:buildmaster-more-future-imports into launchpad:master.
Commit message:
Convert remaining lp.buildmaster tests to preferred __future__ imports
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/395340
I missed a few of these in 91b5e52567627cd13f7030b42c189c72d657e762, notably the pagetests.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:buildmaster-more-future-imports into launchpad:master.
diff --git a/lib/lp/buildmaster/stories/builder-views.txt b/lib/lp/buildmaster/stories/builder-views.txt
index 5637eb7..f93d409 100644
--- a/lib/lp/buildmaster/stories/builder-views.txt
+++ b/lib/lp/buildmaster/stories/builder-views.txt
@@ -18,13 +18,13 @@ Let's instantiate the view for +index:
>>> builder_view = getMultiAdapter((builder, request), name="+index")
- >>> print builder_view.page_title
+ >>> print(builder_view.page_title)
Builder ...Bob The Builder...
The BuilderView provides a helper for the text to use on the toggle
mode button.
- >>> print builder_view.toggle_mode_text
+ >>> print(builder_view.toggle_mode_text)
Switch to manual-mode
@@ -33,7 +33,7 @@ mode button.
Let's instantiate a view for +history:
>>> builder_view = getMultiAdapter((builder, request), name="+history")
- >>> print builder_view.page_title
+ >>> print(builder_view.page_title)
Build history
setupBuildList, build a batched list of build records and store it
@@ -60,11 +60,11 @@ by mark. we nee to log in as mark or any other member of admin team
>>> from lp.testing.views import create_initialized_view
>>> login("foo.bar@xxxxxxxxxxxxx")
>>> builder_view = create_initialized_view(builder, name="+edit")
- >>> print builder_view.page_title
+ >>> print(builder_view.page_title)
Change details for builder ...Bob The Builder...
>>> for field_name in builder_view.field_names:
- ... print field_name
+ ... print(field_name)
name
title
processors
@@ -79,24 +79,24 @@ by mark. we nee to log in as mark or any other member of admin team
active
>>> for action in builder_view.actions:
- ... print action.label
+ ... print(action.label)
Change
The BuilderEditView also has a next_url property for redirecting after
a successful form submission.
- >>> print builder_view.next_url
+ >>> print(builder_view.next_url)
http://launchpad.test/builders/bob
The BuilderEditView can be used to update the relevant fields on the
builder.
>>> def print_builder_info(builder):
- ... print "%s: manual=%s, vm_host=%s." % (
+ ... print("%s: manual=%s, vm_host=%s." % (
... builder.name,
... builder.manual,
... builder.vm_host,
- ... )
+ ... ))
>>> print_builder_info(builder)
bob: manual=False, vm_host=None.
@@ -114,7 +114,7 @@ builder.
After editing a builder, a relevant notification is added to the view.
>>> for notification in builder_view.request.notifications:
- ... print notification.message
+ ... print(notification.message)
The builder "Bob The Builder" was updated successfully.
@@ -174,15 +174,15 @@ is widely available:
* Frog 'currentjob' exists;
* Frog has no 'failnotes';
- >>> print frog.builderok
+ >>> print(frog.builderok)
True
>>> build_set = getUtility(IBinaryPackageBuildSet)
>>> build = build_set.getByQueueEntry(frog.currentjob)
- >>> print build.title
+ >>> print(build.title)
i386 build of privacy-test 666 in ubuntutest breezy-autotest RELEASE
- >>> print frog.failnotes
+ >>> print(frog.failnotes)
None
Accessing the view for $builder/+index as a Foo Bar, which has
@@ -196,14 +196,14 @@ all the 'private' information is exposed.
>>> empty_request = LaunchpadTestRequest(form={})
>>> admin_view = getMultiAdapter((frog, empty_request), name="+index")
- >>> print admin_view.context.builderok
+ >>> print(admin_view.context.builderok)
True
>>> build = build_set.getByQueueEntry(admin_view.context.currentjob)
- >>> print build.title
+ >>> print(build.title)
i386 build of privacy-test 666 in ubuntutest breezy-autotest RELEASE
- >>> print admin_view.context.failnotes
+ >>> print(admin_view.context.failnotes)
None
>>> import datetime
@@ -211,7 +211,7 @@ all the 'private' information is exposed.
>>> from zope.security.proxy import removeSecurityProxy
>>> removeSecurityProxy(private_job).date_started = (
... datetime.datetime.now(pytz.UTC) - datetime.timedelta(10))
- >>> print admin_view.current_build_duration
+ >>> print(admin_view.current_build_duration)
10 days...
Once the private job is gone, Frog 'real' details are exposed publicly
@@ -292,16 +292,16 @@ contains the following attributes:
>>> builder_category = builderset_view.nonvirt_builders
- >>> print builder_category
+ >>> print(builder_category)
<...BuilderCategory ...>
- >>> print builder_category.title
+ >>> print(builder_category.title)
Non-virtual build status
- >>> print builder_category.virtualized
+ >>> print(builder_category.virtualized)
False
- >>> print builder_category.groups[0]
+ >>> print(builder_category.groups[0])
<...BuilderGroup ...>
Similarly to what is done in the UI, we have a helper that prints the
@@ -309,10 +309,10 @@ grouped builders within a category in a easy manner.
>>> def print_category(category):
... for group in category.groups:
- ... print group.processor_name, \
- ... group.number_of_available_builders, \
- ... group.queue_size, \
- ... group.duration
+ ... print(group.processor_name,
+ ... group.number_of_available_builders,
+ ... group.queue_size,
+ ... group.duration)
>>> print_category(builder_category)
386 2 1 0:00:30
@@ -334,16 +334,16 @@ Each `BuilderGroup` contains the following attributes:
>>> [i386_group, amd64_group, hppa_group] = builder_category.groups
- >>> print i386_group.processor_name
+ >>> print(i386_group.processor_name)
386
- >>> print i386_group.number_of_available_builders
+ >>> print(i386_group.number_of_available_builders)
2
- >>> print i386_group.queue_size
+ >>> print(i386_group.queue_size)
1
- >>> print i386_group.duration
+ >>> print(i386_group.duration)
0:00:30
The 'virtual' builder category is also available in BuilderSetView as a
@@ -351,10 +351,10 @@ The 'virtual' builder category is also available in BuilderSetView as a
>>> builder_category = builderset_view.virt_builders
- >>> print builder_category.title
+ >>> print(builder_category.title)
Virtual build status
- >>> print builder_category.virtualized
+ >>> print(builder_category.virtualized)
True
>>> print_category(builder_category)
diff --git a/lib/lp/buildmaster/stories/xx-builder-page.txt b/lib/lp/buildmaster/stories/xx-builder-page.txt
index c27de04..36d4c33 100644
--- a/lib/lp/buildmaster/stories/xx-builder-page.txt
+++ b/lib/lp/buildmaster/stories/xx-builder-page.txt
@@ -16,15 +16,15 @@ builder state. In the sampledata, the builder 'bob' is building
>>> anon_browser.open("http://launchpad.test/builders")
>>> anon_browser.getLink("bob").click()
- >>> print extract_text(find_main_content(anon_browser.contents))
+ >>> print(extract_text(find_main_content(anon_browser.contents)))
Bob The Builder
...
Bob The Builder builds 386 binaries and is owned by Launchpad Buildd
Admins.
...
- >>> print extract_text(find_portlet(
- ... anon_browser.contents, 'View full history Current status'))
+ >>> print(extract_text(find_portlet(
+ ... anon_browser.contents, 'View full history Current status')))
View full history Current status
Building i386 build of mozilla-firefox 0.9 in ubuntu hoary RELEASE
Started ... ago.
@@ -37,8 +37,8 @@ timezone. This way they can easily find out if they are reading
outdated information.
>>> user_browser.open(anon_browser.url)
- >>> print extract_text(find_portlet(
- ... user_browser.contents, 'View full history Current status'))
+ >>> print(extract_text(find_portlet(
+ ... user_browser.contents, 'View full history Current status')))
View full history Current status
Building i386 build of mozilla-firefox 0.9 in ubuntu hoary RELEASE
Started ... ago.
@@ -50,8 +50,8 @@ The anonymous user can see the builder details portlet and it contains
information about the builder itself, like name, architecture and
location.
- >>> print extract_text(
- ... find_portlet(anon_browser.contents, 'Builder information'))
+ >>> print(extract_text(
+ ... find_portlet(anon_browser.contents, 'Builder information')))
Builder information
Architectures: 386
Location: http://localhost:8221/
@@ -73,22 +73,22 @@ Idle builders show more details of their status.
... builder = factory.makeBuilder(name='victim')
... builder.setCleanStatus(BuilderCleanStatus.DIRTY)
>>> anon_browser.open('http://launchpad.test/builders/victim')
- >>> print extract_text(find_portlet(
- ... anon_browser.contents, 'View full history Current status'))
+ >>> print(extract_text(find_portlet(
+ ... anon_browser.contents, 'View full history Current status')))
View full history Current status
Cleaning
>>> with admin_logged_in():
... builder.setCleanStatus(BuilderCleanStatus.CLEANING)
>>> anon_browser.open(anon_browser.url)
- >>> print extract_text(find_portlet(
- ... anon_browser.contents, 'View full history Current status'))
+ >>> print(extract_text(find_portlet(
+ ... anon_browser.contents, 'View full history Current status')))
View full history Current status
Cleaning
>>> with admin_logged_in():
... builder.setCleanStatus(BuilderCleanStatus.CLEAN)
>>> anon_browser.open(anon_browser.url)
- >>> print extract_text(find_portlet(
- ... anon_browser.contents, 'View full history Current status'))
+ >>> print(extract_text(find_portlet(
+ ... anon_browser.contents, 'View full history Current status')))
View full history Current status
Idle
@@ -149,7 +149,7 @@ effect immediately.
# We use backslashreplace because the page title includes smart quotes.
>>> from lp.services.helpers import backslashreplace
- >>> print backslashreplace(cprov_browser.title)
+ >>> print(backslashreplace(cprov_browser.title))
Change details for...
>>> title = cprov_browser.getControl(name="field.title")
@@ -161,7 +161,7 @@ effect immediately.
# Submitting the change details form redirects to the index page
# for the builder.
- >>> print backslashreplace(cprov_browser.title)
+ >>> print(backslashreplace(cprov_browser.title))
Donkey builder : Build Farm
Then restores it once he realises his mistake.
@@ -176,7 +176,7 @@ automatic (AUTO) mode.
>>> details_portlet = find_portlet(
... cprov_browser.contents, "Builder information")
- >>> print str(extract_text(details_portlet))
+ >>> print(str(extract_text(details_portlet)))
Builder information
Architectures: amd64 hppa
Location: http://localhost:8221/
@@ -193,7 +193,7 @@ He can see now, in the details portlet that the builder is in manual-mode.
>>> details_portlet = find_portlet(
... cprov_browser.contents, "Builder information")
- >>> print str(extract_text(details_portlet))
+ >>> print(str(extract_text(details_portlet)))
Builder information
...
Mode: This builder is in manual-mode and not accepting jobs from the
@@ -234,7 +234,7 @@ transient failures or is used for another purpose.
>>> cprov_browser.open('http://launchpad.test/builders')
>>> cprov_browser.getLink('bob').click()
- >>> print backslashreplace(cprov_browser.title)
+ >>> print(backslashreplace(cprov_browser.title))
Bob The Builder : Build Farm
Celso can toggle the active bit using the Change details form.
@@ -252,7 +252,7 @@ Farm list. Celso cannot see the link to it.
>>> cprov_browser.getLink("Build Farm").click()
- >>> print extract_text(find_main_content(cprov_browser.contents))
+ >>> print(extract_text(find_main_content(cprov_browser.contents)))
The Launchpad build farm
Register a new build machine
1 available build machine, 1 disabled and 0 building of a total
@@ -273,7 +273,7 @@ Farm list. Celso cannot see the link to it.
But Celso can access the deactivated builder via its URL.
>>> cprov_browser.open('http://launchpad.test/+builds/bob')
- >>> print backslashreplace(cprov_browser.title)
+ >>> print(backslashreplace(cprov_browser.title))
Bob The Builder : Build Farm
@@ -292,7 +292,7 @@ Nor is the toggle mode control included on the index page.
>>> user_browser.getControl(name="field.actions.update")
Traceback (most recent call last):
- LookupError: name 'field.actions.update'
+ LookupError: name ...'field.actions.update'
...
Nor can they access the edit page directly via URL.
@@ -311,7 +311,7 @@ The same is true for the anonymous user:
>>> anon_browser.getControl(name="field.actions.update")
Traceback (most recent call last):
- LookupError: name 'field.actions.update'
+ LookupError: name ...'field.actions.update'
...
>>> anon_browser.open("http://localhost/+builds/bob/+edit")
diff --git a/lib/lp/buildmaster/stories/xx-buildfarm-index.txt b/lib/lp/buildmaster/stories/xx-buildfarm-index.txt
index 4ceebda..5fd0cf5 100644
--- a/lib/lp/buildmaster/stories/xx-buildfarm-index.txt
+++ b/lib/lp/buildmaster/stories/xx-buildfarm-index.txt
@@ -12,7 +12,7 @@ finally by name. A short textual description of their status is listed
in the 'Status' column. There are also 2 portlets on the right-side
containing the build queue status summary for each build domain.
- >>> print extract_text(find_main_content(anon_browser.contents))
+ >>> print(extract_text(find_main_content(anon_browser.contents)))
The Launchpad build farm
1 available build machine, 1 disabled and 1 building of a total of
2 registered.
@@ -30,8 +30,8 @@ containing the build queue status summary for each build domain.
When building, the 'Status' column contains a link to the
corresponding 'Build' page.
- >>> print anon_browser.getLink(
- ... 'i386 build of mozilla-firefox 0.9').url
+ >>> print(anon_browser.getLink(
+ ... 'i386 build of mozilla-firefox 0.9').url)
http://launchpad.test/ubuntu/+source/mozilla-firefox/0.9/+build/8
The build status portlets contain the number of builds waiting
@@ -40,14 +40,14 @@ supported processor on each separated build domain, 'nonvirt'
(PRIMARY and PARTNER) and 'virt'.
>>> anon_browser.reload()
- >>> print extract_text(
- ... find_tag_by_id(anon_browser.contents, 'nonvirt-queue-status'))
+ >>> print(extract_text(
+ ... find_tag_by_id(anon_browser.contents, 'nonvirt-queue-status')))
Non-virtual build status
Architecture Builders Queue
386 1 1 job (1 minute)
- >>> print extract_text(
- ... find_tag_by_id(anon_browser.contents, 'virt-queue-status',))
+ >>> print(extract_text(
+ ... find_tag_by_id(anon_browser.contents, 'virt-queue-status')))
Virtual build status
Architecture Builders Queue
386 0 empty
@@ -73,8 +73,8 @@ the corresponding portlet with their estimated duration as well.
>>> logout()
>>> anon_browser.reload()
- >>> print extract_text(
- ... find_tag_by_id(anon_browser.contents, 'virt-queue-status'))
+ >>> print(extract_text(
+ ... find_tag_by_id(anon_browser.contents, 'virt-queue-status')))
Virtual build status
Architecture Builders Queue
386 0 1 job (1 minute)
@@ -89,14 +89,14 @@ record already exists, we must manually set it to non-virtualized too.
>>> logout()
>>> anon_browser.reload()
- >>> print extract_text(
- ... find_tag_by_id(anon_browser.contents, 'virt-queue-status'))
+ >>> print(extract_text(
+ ... find_tag_by_id(anon_browser.contents, 'virt-queue-status')))
Virtual build status
Architecture Builders Queue
386 0 empty
- >>> print extract_text(
- ... find_tag_by_id(anon_browser.contents, 'nonvirt-queue-status'))
+ >>> print(extract_text(
+ ... find_tag_by_id(anon_browser.contents, 'nonvirt-queue-status')))
Non-virtual build status
Architecture Builders Queue
386 1 2 jobs (2 minutes)
@@ -124,7 +124,7 @@ Administrators can create new builders.
>>> admin_browser.getLink("Register a new build machine").click()
- >>> print admin_browser.title
+ >>> print(admin_browser.title)
Register a new...
Registering a new builder involves setting its name, title and corresponding
@@ -148,14 +148,14 @@ to the builder.
By default, builders are created as 'Publicly Visible', although the
administrator can change this value during creation time.
- >>> print admin_browser.getControl('Publicly Visible').selected
+ >>> print(admin_browser.getControl('Publicly Visible').selected)
True
>>> admin_browser.getControl('Publicly Visible').selected = False
Builder as created as 'non-virtual' by default, but the administrator
can also modify that while creating a builder.
- >>> print admin_browser.getControl('Virtualized').selected
+ >>> print(admin_browser.getControl('Virtualized').selected)
False
>>> admin_browser.getControl('VM host').value
''
@@ -172,7 +172,7 @@ just-created builder page.
>>> from lp.services.helpers import backslashreplace
>>> admin_browser.getControl("Register builder").click()
- >>> print backslashreplace(admin_browser.title)
+ >>> print(backslashreplace(admin_browser.title))
Tubaina : Build Farm
>>> 'amd64 and hppa' in admin_browser.contents
True
diff --git a/lib/lp/buildmaster/tests/test_doc.py b/lib/lp/buildmaster/tests/test_doc.py
index 0a1cfd6..15cebaa 100644
--- a/lib/lp/buildmaster/tests/test_doc.py
+++ b/lib/lp/buildmaster/tests/test_doc.py
@@ -19,6 +19,7 @@ from lp.testing.layers import (
LaunchpadFunctionalLayer,
LaunchpadZopelessLayer,
)
+from lp.testing.pages import setUpGlobs
from lp.testing.systemdocs import (
LayeredDocFileSuite,
setGlobs,
@@ -50,11 +51,11 @@ def buildmasterTearDown(test):
special = {
'builder.txt': LayeredDocFileSuite(
'../doc/builder.txt',
- setUp=setUp, tearDown=tearDown,
+ setUp=lambda test: setUp(test, future=True), tearDown=tearDown,
layer=LaunchpadFunctionalLayer),
'buildqueue.txt': LayeredDocFileSuite(
'../doc/buildqueue.txt',
- setUp=setUp, tearDown=tearDown,
+ setUp=lambda test: setUp(test, future=True), tearDown=tearDown,
layer=LaunchpadFunctionalLayer),
}
@@ -62,4 +63,5 @@ special = {
def test_suite():
return build_test_suite(
here, special, layer=LaunchpadZopelessLayer,
- setUp=lambda test: setUp(test, future=True))
+ setUp=lambda test: setUp(test, future=True),
+ pageTestsSetUp=lambda test: setUpGlobs(test, future=True))