← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:fix-py3-services-future-imports into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:fix-py3-services-future-imports into launchpad:master.

Commit message:
Fix a few test failures with lp.services future imports

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/398521
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:fix-py3-services-future-imports into launchpad:master.
diff --git a/lib/lp/services/gpg/doc/gpg-encryption.txt b/lib/lp/services/gpg/doc/gpg-encryption.txt
index 7bef091..952738a 100644
--- a/lib/lp/services/gpg/doc/gpg-encryption.txt
+++ b/lib/lp/services/gpg/doc/gpg-encryption.txt
@@ -57,7 +57,7 @@ cipher constains the encrypted content.
 Storing the raw password may compromise the security, but is the
 only way we can decrypt the cipher content.
 
-    >>> password = 'test'
+    >>> password = six.ensure_str('test')
     >>> plain = decrypt_content(cipher, password)
 
 voilá, the same content shows up again. 
@@ -69,7 +69,7 @@ Verify if the encrytion process support passing another charset string
 
     >>> content = u'a\xe7ucar'
     >>> cipher = gpghandler.encryptContent(content.encode('iso-8859-1'), key)
-    >>> plain = decrypt_content(cipher, 'test')    
+    >>> plain = decrypt_content(cipher, six.ensure_str('test'))
     >>> print(backslashreplace(plain.decode('iso-8859-1')))
     a\xe7ucar
 
@@ -85,7 +85,7 @@ Decrypt a unicode content:
     >>> content = u'a\xe7ucar'
     >>> cipher = gpghandler.encryptContent(content.encode('iso-8859-1'), key)
     >>> cipher = six.ensure_text(cipher)
-    >>> plain = decrypt_content(cipher, 'test')    
+    >>> plain = decrypt_content(cipher, six.ensure_str('test'))
     Traceback (most recent call last):
     ...
     TypeError: Content must be bytes.
@@ -113,7 +113,7 @@ What about a message encrypted for an unknown key.
     ... =LQK5
     ... -----END PGP MESSAGE-----
     ... """
-    >>> plain = decrypt_content(cipher, 'test')    
+    >>> plain = decrypt_content(cipher, six.ensure_str('test'))
     >>> plain is None
     True
 
diff --git a/lib/lp/services/webapp/doc/webapp-authorization.txt b/lib/lp/services/webapp/doc/webapp-authorization.txt
index 7269cbd..b24ae1b 100644
--- a/lib/lp/services/webapp/doc/webapp-authorization.txt
+++ b/lib/lp/services/webapp/doc/webapp-authorization.txt
@@ -25,7 +25,7 @@ If the permission doesn't exist, it raises an error:
     >>> check_permission('mushroom.Badger', sample_person)
     Traceback (most recent call last):
     ...
-    ValueError: ('Undefined permission ID', 'mushroom.Badger')
+    ValueError: ('Undefined permission ID', ...'mushroom.Badger')
     >>> logout()
 
 
diff --git a/lib/lp/services/webapp/doc/xmlrpc-infrastructure.txt b/lib/lp/services/webapp/doc/xmlrpc-infrastructure.txt
index 747e15a..3707bcf 100644
--- a/lib/lp/services/webapp/doc/xmlrpc-infrastructure.txt
+++ b/lib/lp/services/webapp/doc/xmlrpc-infrastructure.txt
@@ -8,10 +8,10 @@ LaunchpadXMLRPCView.
 
 You get access to the context and the request, as you would expect.
 
-    >>> viewobj.context
-    'somecontext'
-    >>> viewobj.request
-    'somerequest'
+    >>> print(viewobj.context)
+    somecontext
+    >>> print(viewobj.request)
+    somerequest
 
 Like a LaunchpadView, you can get 'self.user', which is the currently logged-in
 user, or None when there is no user logged in.
diff --git a/lib/lp/services/webservice/doc/launchpadlib.txt b/lib/lp/services/webservice/doc/launchpadlib.txt
index 30e7142..a44050e 100644
--- a/lib/lp/services/webservice/doc/launchpadlib.txt
+++ b/lib/lp/services/webservice/doc/launchpadlib.txt
@@ -4,12 +4,14 @@ Just to show that we're actually talking to the appserver, first check to see
 if a specific user exists...
 
     >>> browser = Browser()
-    >>> browser.addHeader('Authorization', 'Basic foo.bar@xxxxxxxxxxxxx:test')
+    >>> browser.addHeader(
+    ...     'Authorization',
+    ...     six.ensure_str('Basic foo.bar@xxxxxxxxxxxxx:test'))
     >>> from lp.testing.layers import BaseLayer
     >>> root_url = BaseLayer.appserver_root_url()
     >>> browser.open(root_url)
-    >>> browser.vhost
-    'http://launchpad.test'
+    >>> print(browser.vhost)
+    http://launchpad.test
     >>> browser.urlpath
     '/'
 
@@ -25,7 +27,7 @@ if a specific user exists...
     >>> browser.getControl(name='field.name').value = 'stimpy'
     >>> browser.getControl('Display Name').value = 'Stimpson J. Cat'
     >>> browser.getControl('Create').click()
-    >>> browser.vhost
-    'http://launchpad.test'
+    >>> print(browser.vhost)
+    http://launchpad.test
     >>> browser.urlpath
     '/~stimpy'
diff --git a/lib/lp/testing/browser.py b/lib/lp/testing/browser.py
index aed02bc..155eccf 100644
--- a/lib/lp/testing/browser.py
+++ b/lib/lp/testing/browser.py
@@ -20,6 +20,7 @@ import __future__
 import ssl
 
 from lazr.uri import URI
+import six
 from urllib3 import PoolManager
 from wsgiproxy.proxies import TransparentProxy
 from wsgiproxy.urllib3_client import HttpClient
@@ -81,3 +82,4 @@ def setUp(test):
     test.globs['print_feedback_messages'] = print_feedback_messages
     test.globs['extract_text'] = extract_text
     test.globs['pretty'] = PrettyPrinter(width=1).pformat
+    test.globs['six'] = six