← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:registry-pagetests-future-imports-prepare into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:registry-pagetests-future-imports-prepare into launchpad:master.

Commit message:
Prepare lp.registry pagetests for unicode_literals

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/392131

This applies various non-mechanical adjustments to tests that would otherwise start failing once the pagetests in lp.registry are converted to our preferred __future__ imports.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:registry-pagetests-future-imports-prepare into launchpad:master.
diff --git a/lib/lp/registry/stories/announcements/xx-announcements.txt b/lib/lp/registry/stories/announcements/xx-announcements.txt
index ca0f13e..e0ffc0b 100644
--- a/lib/lp/registry/stories/announcements/xx-announcements.txt
+++ b/lib/lp/registry/stories/announcements/xx-announcements.txt
@@ -727,19 +727,23 @@ hosted in Launchpad:
     ...              nopriv_browser.headers['content-type'],
     ...              nopriv_browser.url)
     No Errors
-    >>> 'Announcements published via Launchpad' in nopriv_browser.contents
+    >>> 'Announcements published via Launchpad' in (
+    ...     six.ensure_text(nopriv_browser.contents))
     True
-    >>> '[tomcat] Tomcat announcement headline' in nopriv_browser.contents
+    >>> '[tomcat] Tomcat announcement headline' in (
+    ...     six.ensure_text(nopriv_browser.contents))
     True
-    >>> '[apache] Modified headline' in nopriv_browser.contents
+    >>> '[apache] Modified headline' in (
+    ...     six.ensure_text(nopriv_browser.contents))
     True
 
 It excludes retracted and future announcements too:
 
     >>> "[guadalinex] Kubuntu announcement headline" in (
-    ...     nopriv_browser.contents)
+    ...     six.ensure_text(nopriv_browser.contents))
     False
-    >>> "[jokosher] Jokosher announcement headline" in nopriv_browser.contents
+    >>> "[jokosher] Jokosher announcement headline" in (
+    ...     six.ensure_text(nopriv_browser.contents))
     False
 
 The announcements are stored as plain text, but the text-to-html formatter
diff --git a/lib/lp/registry/stories/distributionmirror/xx-distribution-countrymirrors.txt b/lib/lp/registry/stories/distributionmirror/xx-distribution-countrymirrors.txt
index 399f15d..eea6781 100644
--- a/lib/lp/registry/stories/distributionmirror/xx-distribution-countrymirrors.txt
+++ b/lib/lp/registry/stories/distributionmirror/xx-distribution-countrymirrors.txt
@@ -21,10 +21,11 @@ archive mirrors, plus the canonical one.
     83.196.46.77
     >>> print browser.headers['X-REQUEST-REMOTE_ADDR']
     127.0.0.1
-    >>> sorted(browser.contents.split('\n'))
-    ['http://archive.ubuntu.com/ubuntu/',
-     'http://localhost:11375/archive-mirror/',
-     'http://localhost:11375/valid-mirror/']
+    >>> for url in sorted(browser.contents.split('\n')):
+    ...     print(url)
+    http://archive.ubuntu.com/ubuntu/
+    http://localhost:11375/archive-mirror/
+    http://localhost:11375/valid-mirror/
 
 Using a request with no IP address information will give us only the
 canonical mirror.
@@ -33,8 +34,9 @@ canonical mirror.
     ...     'http://launchpad.test/ubuntu/+countrymirrors-archive')
     >>> print anon_browser.headers['X-Generated-For-Country']
     Unknown
-    >>> sorted(anon_browser.contents.split('\n'))
-    ['http://archive.ubuntu.com/ubuntu/']
+    >>> for url in sorted(anon_browser.contents.split('\n')):
+    ...     print(url)
+    http://archive.ubuntu.com/ubuntu/
 
 Note that unofficial mirrors are not included in the listings.
 
@@ -49,9 +51,10 @@ Note that unofficial mirrors are not included in the listings.
     # http://localhost:11375/archive-mirror/ is not included in the list
     # anymore.
     >>> browser.open('http://launchpad.test/ubuntu/+countrymirrors-archive')
-    >>> sorted(browser.contents.split('\n'))
-    ['http://archive.ubuntu.com/ubuntu/',
-     'http://localhost:11375/valid-mirror/']
+    >>> for url in sorted(browser.contents.split('\n')):
+    ...     print(url)
+    http://archive.ubuntu.com/ubuntu/
+    http://localhost:11375/valid-mirror/
 
 Also, the +countrymirrors-archive page is only available for the Ubuntu
 distribution.
diff --git a/lib/lp/registry/stories/gpg-coc/xx-gpg-coc.txt b/lib/lp/registry/stories/gpg-coc/xx-gpg-coc.txt
index bcca447..b7ab998 100644
--- a/lib/lp/registry/stories/gpg-coc/xx-gpg-coc.txt
+++ b/lib/lp/registry/stories/gpg-coc/xx-gpg-coc.txt
@@ -34,7 +34,7 @@ Start out with a clean page containing no imported keys:
     >>> browser.getControl(name='DEACTIVATE_GPGKEY')
     Traceback (most recent call last):
     ...
-    LookupError: name 'DEACTIVATE_GPGKEY'
+    LookupError: name ...'DEACTIVATE_GPGKEY'
     ...
 
 Claim OpenPGP key:
@@ -108,7 +108,7 @@ Import the secret keys needed for this test:
 access the current IGpghandler instance to access this key and decrypt the
 message.
 
-    >>> body = decrypt_content(cipher_body, 'test')
+    >>> body = decrypt_content(cipher_body, six.ensure_str('test'))
 
 Extract the token URL from the email:
 
@@ -249,7 +249,7 @@ If they sign a different text, they get an error message.
     >>> login(ANONYMOUS)
     >>> key = import_secret_test_key('sign.only@xxxxxxxxxxxxxxxxx')
     >>> bad = gpghandler.signContent(
-    ...     'This is not the verification message!', key, 'test')
+    ...     b'This is not the verification message!', key, 'test')
     >>> logout()
 
     >>> browser.getControl('Signed text').value = bad
@@ -286,7 +286,7 @@ A419AE861E88BC9E04B9C26FBA2B9389DFD20543:
 If they sign the text correctly, they are redirected to their home page.
 
     >>> login(ANONYMOUS)
-    >>> good = gpghandler.signContent(str(verification_content), key, 'test')
+    >>> good = gpghandler.signContent(bytes(verification_content), key, 'test')
     >>> logout()
 
     >>> browser.getControl('Signed text').value = good
@@ -505,7 +505,7 @@ Get the token from the body of the email sent.
     >>> from_addr, to_addrs, raw_msg = stub.test_emails.pop()
     >>> msg = email.message_from_string(raw_msg)
     >>> cipher_body = msg.get_payload(decode=1)
-    >>> body = decrypt_content(cipher_body, 'test')
+    >>> body = decrypt_content(cipher_body, six.ensure_str('test'))
     >>> link = re.findall(r'http.*/token/.*', body)[0]
     >>> token = re.sub(r'.*token/', '', link)
     >>> token_url = 'http://launchpad.test/token/%s' % token.encode('ascii')
diff --git a/lib/lp/registry/stories/mailinglists/lifecycle.txt b/lib/lp/registry/stories/mailinglists/lifecycle.txt
index d18630a..ca20341 100644
--- a/lib/lp/registry/stories/mailinglists/lifecycle.txt
+++ b/lib/lp/registry/stories/mailinglists/lifecycle.txt
@@ -184,16 +184,16 @@ An inactive mailing list can be reactivated.
 
     >>> browser.getLink(url='+mailinglist').click()
     >>> browser.getControl('Reactivate this Mailing List').click()
-    >>> mailing_list_status_message(browser.contents)
-    ''
+    >>> print(mailing_list_status_message(browser.contents))
+    <BLANKLINE>
     >>> print_feedback_messages(browser.contents)
     The mailing list will be reactivated within a few minutes.
     >>> act()
     >>> transaction.commit()
 
     >>> browser.getLink(url='+mailinglist').click()
-    >>> mailing_list_status_message(browser.contents)
-    ''
+    >>> print(mailing_list_status_message(browser.contents))
+    <BLANKLINE>
 
 This does not restore the mailing list as the team's contact method:
 
diff --git a/lib/lp/registry/stories/mailinglists/subscriptions.txt b/lib/lp/registry/stories/mailinglists/subscriptions.txt
index c0a3408..d993e0a 100644
--- a/lib/lp/registry/stories/mailinglists/subscriptions.txt
+++ b/lib/lp/registry/stories/mailinglists/subscriptions.txt
@@ -115,7 +115,7 @@ not been completed (specifically, Mailman hasn't constructed it yet).
     ...     name='field.subscription.testing-spanish-team')
     Traceback (most recent call last):
     ...
-    LookupError: name 'field.subscription.testing-spanish-team'
+    LookupError: name ...'field.subscription.testing-spanish-team'
     ...
 
 Carlos can subscribe to a list using his preferred email address.  Such
@@ -244,7 +244,7 @@ screen.
     ...     name='field.subscription.rosetta-admins')
     Traceback (most recent call last):
     ...
-    LookupError: name 'field.subscription.rosetta-admins'
+    LookupError: name ...'field.subscription.rosetta-admins'
     ...
 
 Jdub will become a member of the team's mailing list as soon as he has
@@ -286,7 +286,7 @@ list is not presented.
     >>> browser.getControl(name='mailinglist_subscribe')
     Traceback (most recent call last):
     ...
-    LookupError: name 'mailinglist_subscribe'
+    LookupError: name ...'mailinglist_subscribe'
     ...
 
 Of course, the option to subscribe to the mailing list isn't present
@@ -300,7 +300,7 @@ for teams that don't have mailing lists.
     >>> browser.getControl(name='mailinglist_subscribe')
     Traceback (most recent call last):
     ...
-    LookupError: name 'mailinglist_subscribe'
+    LookupError: name ...'mailinglist_subscribe'
     ...
 
 And the option is also missing from the sign-up pages of teams that
@@ -315,7 +315,7 @@ Overview.)
     >>> browser.getControl(name='mailinglist_subscribe')
     Traceback (most recent call last):
     ...
-    LookupError: name 'mailinglist_subscribe'
+    LookupError: name ...'mailinglist_subscribe'
     ...
 
 
diff --git a/lib/lp/registry/stories/object/xx-nameblacklist.txt b/lib/lp/registry/stories/object/xx-nameblacklist.txt
index 070285c..c547394 100644
--- a/lib/lp/registry/stories/object/xx-nameblacklist.txt
+++ b/lib/lp/registry/stories/object/xx-nameblacklist.txt
@@ -56,5 +56,5 @@ happily without generating
     >>> admin_browser.getControl('Save').click()
 
     >>> print_feedback_messages(admin_browser.contents)
-    >>> "has been blocked" in admin_browser.contents
+    >>> "has been blocked" in six.ensure_text(admin_browser.contents)
     False
diff --git a/lib/lp/registry/stories/product/xx-product-edit.txt b/lib/lp/registry/stories/product/xx-product-edit.txt
index 28a6cef..8f82dd3 100644
--- a/lib/lp/registry/stories/product/xx-product-edit.txt
+++ b/lib/lp/registry/stories/product/xx-product-edit.txt
@@ -198,12 +198,12 @@ registrant fields.
     >>> browser.getControl('Maintainer')
     Traceback (most recent call last):
     ...
-    LookupError: label 'Maintainer'
+    LookupError: label ...'Maintainer'
     ...
     >>> browser.getControl('Registrant')
     Traceback (most recent call last):
     ...
-    LookupError: label 'Registrant'
+    LookupError: label ...'Registrant'
     ...
 
 But registry experts can change a product name and set an alias.
diff --git a/lib/lp/registry/stories/product/xx-product-files.txt b/lib/lp/registry/stories/product/xx-product-files.txt
index 5751b75..fff1d46 100644
--- a/lib/lp/registry/stories/product/xx-product-files.txt
+++ b/lib/lp/registry/stories/product/xx-product-files.txt
@@ -122,7 +122,7 @@ A project owner should not see the delete button when there are no files.
     >>> tbird_owner.getControl('Delete Files')
     Traceback (most recent call last):
     ...
-    LookupError: label 'Delete Files'
+    LookupError: label ...'Delete Files'
     ...
 
 
@@ -474,7 +474,7 @@ And no "Delete Files" button is shown.
     >>> non_owner.getControl('Delete Files')
     Traceback (most recent call last):
     ...
-    LookupError: label 'Delete Files'
+    LookupError: label ...'Delete Files'
     ...
 
 As with the other listing, the administrators have the option to
diff --git a/lib/lp/registry/stories/project/xx-project-edit.txt b/lib/lp/registry/stories/project/xx-project-edit.txt
index ad2a45c..2a7b710 100644
--- a/lib/lp/registry/stories/project/xx-project-edit.txt
+++ b/lib/lp/registry/stories/project/xx-project-edit.txt
@@ -144,12 +144,12 @@ there are fewer fields available.
     >>> expert_browser.getControl('Maintainer')
     Traceback (most recent call last):
     ...
-    LookupError: label 'Maintainer'
+    LookupError: label ...'Maintainer'
     ...
     >>> expert_browser.getControl('Registrant')
     Traceback (most recent call last):
     ...
-    LookupError: label 'Registrant'
+    LookupError: label ...'Registrant'
     ...
 
     >>> expert_browser.getControl('Name').value = 'newer-name'
diff --git a/lib/lp/registry/stories/team-polls/edit-poll.txt b/lib/lp/registry/stories/team-polls/edit-poll.txt
index 7265ff3..fc4a9de 100644
--- a/lib/lp/registry/stories/team-polls/edit-poll.txt
+++ b/lib/lp/registry/stories/team-polls/edit-poll.txt
@@ -88,7 +88,7 @@ It's also not possible to edit a poll that's already closed.
     >>> team_admin_browser.url
     'http://launchpad.test/~ubuntu-team/+poll/director-2004'
 
-    >>> 'Voting has closed' in team_admin_browser.contents
+    >>> 'Voting has closed' in six.ensure_text(team_admin_browser.contents)
     True
 
     >>> team_admin_browser.getLink('Change details').click()
diff --git a/lib/lp/registry/stories/team-polls/vote-poll.txt b/lib/lp/registry/stories/team-polls/vote-poll.txt
index 561f330..e6185a7 100644
--- a/lib/lp/registry/stories/team-polls/vote-poll.txt
+++ b/lib/lp/registry/stories/team-polls/vote-poll.txt
@@ -80,7 +80,7 @@ yet.
     >>> team_admin_browser.open(
     ...   'http://launchpad.test/~ubuntu-team/+poll/never-closes/+vote')
     >>> not_yet_voted_message = 'You have not yet voted in this poll.'
-    >>> not_yet_voted_message in team_admin_browser.contents
+    >>> not_yet_voted_message in six.ensure_text(team_admin_browser.contents)
     True
 
     >>> team_admin_browser.getControl(name='newoption').value = ["donotvote"]
@@ -141,7 +141,7 @@ It's not possible to vote on closed polls, even if we manually craft the URL.
     >>> team_admin_browser.getControl(name='continue')
     Traceback (most recent call last):
     ...
-    LookupError: name 'continue'
+    LookupError: name ...'continue'
     ...
 
 The same is true for condorcet polls too.
@@ -158,7 +158,7 @@ The same is true for condorcet polls too.
     >>> team_admin_browser.getControl(name='continue')
     Traceback (most recent call last):
     ...
-    LookupError: name 'continue'
+    LookupError: name ...'continue'
     ...
 
     >>> team_admin_browser.open(
diff --git a/lib/lp/registry/stories/team/xx-team-contactemail-xss.txt b/lib/lp/registry/stories/team/xx-team-contactemail-xss.txt
index 1b6856d..1c93d0b 100644
--- a/lib/lp/registry/stories/team/xx-team-contactemail-xss.txt
+++ b/lib/lp/registry/stories/team/xx-team-contactemail-xss.txt
@@ -37,5 +37,6 @@ The error message is also valid and correctly escaped:
 The script we tried to inject is not present, unescaped, anywhere in
 the page:
 
-    >>> '<script>alert("cheezburger");</script>' in admin_browser.contents
+    >>> '<script>alert("cheezburger");</script>' in (
+    ...     six.ensure_text(admin_browser.contents))
     False
diff --git a/lib/lp/registry/stories/team/xx-team-membership.txt b/lib/lp/registry/stories/team/xx-team-membership.txt
index 4288f8e..c035799 100644
--- a/lib/lp/registry/stories/team/xx-team-membership.txt
+++ b/lib/lp/registry/stories/team/xx-team-membership.txt
@@ -1,7 +1,7 @@
 Start out by verifying the members page is sane.
 
     >>> browser.open('http://launchpad.test/~ubuntu-team/+members')
-    >>> 'Ubuntu Team' in browser.contents
+    >>> 'Ubuntu Team' in six.ensure_text(browser.contents)
     True
 
 Let's take a look at Colin's subscription page. Colin is an
@@ -14,7 +14,7 @@ administrator and his subscription never expires.
 
     >>> print browser.title
     Colin Watson's membership : ...Ubuntu Team... team
-    >>> "Active member" in browser.contents
+    >>> "Active member" in six.ensure_text(browser.contents)
     True
     >>> browser.getControl(name='admin').value
     ['yes']
@@ -123,7 +123,7 @@ the administrator control on the membership page.
 
     >>> print jdub_browser.title
     Jeff Waugh's membership : ...Ubuntu Team... team
-    >>> "Active member" in jdub_browser.contents
+    >>> "Active member" in six.ensure_text(jdub_browser.contents)
     True
 
     >>> jdub_browser.getControl(name='admin').value = ['no']
@@ -145,7 +145,7 @@ that the page works and that foo.bar@canonical can access it.
 
     >>> browser.open('http://launchpad.test/~guadamen/+member/name12/')
 
-    >>> 'Declined member' in browser.contents
+    >>> 'Declined member' in six.ensure_text(browser.contents)
     True
 
 Dave Miller is a proposed member in Ubuntu Gnome Team.
@@ -183,7 +183,7 @@ But in the second browser with the stale data we get an error message:
     >>> second_browser.getControl('Approve').click()
     >>> message = (
     ...     'The membership request for Dave Miller has already been processed')
-    >>> message in second_browser.contents
+    >>> message in six.ensure_text(second_browser.contents)
     True
 
 An admin can see the former members of the team.
diff --git a/lib/lp/registry/stories/teammembership/xx-member-renewed-membership.txt b/lib/lp/registry/stories/teammembership/xx-member-renewed-membership.txt
index bec3b86..732ed37 100644
--- a/lib/lp/registry/stories/teammembership/xx-member-renewed-membership.txt
+++ b/lib/lp/registry/stories/teammembership/xx-member-renewed-membership.txt
@@ -40,7 +40,7 @@ membership can't be renewed and explain why.
     >>> browser.getControl('Renew')
     Traceback (most recent call last):
     ...
-    LookupError: label 'Renew'
+    LookupError: label ...'Renew'
     ...
     >>> print extract_text(find_tag_by_id(browser.contents, 'maincontent'))
     Renew membership of Karl Tilbury in Mirror Administrators
@@ -70,7 +70,7 @@ the user to renew that membership because it's not about to expire.
     >>> browser.getControl('Renew')
     Traceback (most recent call last):
     ...
-    LookupError: label 'Renew'
+    LookupError: label ...'Renew'
     ...
     >>> print extract_text(find_tag_by_id(browser.contents, 'maincontent'))
     Renew membership of Karl Tilbury in Mirror Administrators
@@ -127,7 +127,7 @@ Karl can't renew it again, since it's now not set to expire soon.
     >>> browser.getControl('Renew')
     Traceback (most recent call last):
     ...
-    LookupError: label 'Renew'
+    LookupError: label ...'Renew'
     ...
     >>> print extract_text(find_tag_by_id(browser.contents, 'maincontent'))
     Renew membership of Karl Tilbury in Mirror Administrators
diff --git a/lib/lp/registry/stories/teammembership/xx-teammembership.txt b/lib/lp/registry/stories/teammembership/xx-teammembership.txt
index 873a275..5652ceb 100644
--- a/lib/lp/registry/stories/teammembership/xx-teammembership.txt
+++ b/lib/lp/registry/stories/teammembership/xx-teammembership.txt
@@ -227,9 +227,9 @@ have been invited.
     >>> def print_members(contents, type):
     ...     table = find_tag_by_id(contents, type)
     ...     for link in table.findAll('a'):
-    ...         if link.renderContents() != 'Edit' and not link.find('img'):
-    ...             contents = six.ensure_text(link.renderContents())
-    ...             print contents.encode('ascii', 'replace')
+    ...         link_contents = six.ensure_text(link.renderContents())
+    ...         if link_contents != 'Edit' and not link.find('img'):
+    ...             print link_contents.encode('ascii', 'replace')
 
     >>> browser.open('http://launchpad.test/~landscape-developers')
     >>> browser.getLink('All members').click()
diff --git a/lib/lp/registry/stories/webservice/xx-project-registry.txt b/lib/lp/registry/stories/webservice/xx-project-registry.txt
index cd6f1f5..d82ce34 100644
--- a/lib/lp/registry/stories/webservice/xx-project-registry.txt
+++ b/lib/lp/registry/stories/webservice/xx-project-registry.txt
@@ -1027,8 +1027,8 @@ Project release files can be added to a project release using the API
 
     >>> pr_url = '/firefox/1.0/1.0.0'
     >>> ff_100 = webservice.get(pr_url).jsonBody()
-    >>> file_content="first attachment file content \xff"
-    >>> sig_file_content="hash hash hash \xff"
+    >>> file_content=b"first attachment file content \xff"
+    >>> sig_file_content=b"hash hash hash \xff"
     >>> response = webservice.named_post(ff_100['self_link'], 'add_file',
     ...     filename='filename.txt',
     ...     file_content=file_content,
@@ -1067,7 +1067,7 @@ And it has been uploaded correctly.
 The file type and description are optional.  If no signature is
 available then it must be explicitly set to None.
 
-    >>> file_content="second attachment file content"
+    >>> file_content=b"second attachment file content"
     >>> response = webservice.named_post(ff_100['self_link'], 'add_file',
     ...     filename='filename2.txt',
     ...     file_content=file_content,