← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~cjwatson/launchpad/code-browser-tests-future-imports into lp:launchpad

 

Colin Watson has proposed merging lp:~cjwatson/launchpad/code-browser-tests-future-imports into lp:launchpad.

Commit message:
Convert lp.code.browser.tests to Launchpad's preferred __future__ imports.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/code-browser-tests-future-imports/+merge/331758

We've had a reasonably modern set of __future__ imports in standard_template.py for two years now, but in order for that to be useful for later porting work we need to make an effort to retrofit that to existing code; so I thought I'd make a start.  Porting tests first seems the most reasonable strategy in order that we can be more confident in avoiding mistakes while porting production code.  It'll take a while to finish this, but we can do it in stages and stop at any point.  This will also make it easier to convert database models to Storm, which requires calling code to be Unicode-strict.

For the most part Launchpad is pretty clean for a codebase of its size and age, since most textual data of any significance goes through database text columns which are already Unicode; SQLObject-flavoured models tolerate receiving bytes, but switching to Unicode literals mostly just works.  The main adjustments needed in this branch were in diff-related tests, where some of the input files are non-UTF-8.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/code-browser-tests-future-imports into lp:launchpad.
=== modified file 'lib/lp/code/browser/tests/test_bazaar.py'
--- lib/lp/code/browser/tests/test_bazaar.py	2012-09-18 18:36:09 +0000
+++ lib/lp/code/browser/tests/test_bazaar.py	2017-10-04 01:26:22 +0000
@@ -1,8 +1,10 @@
-# Copyright 2009-2012 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2017 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Tests for classes in the lp.code.browser.bazaar module."""
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 __metaclass__ = type
 
 from zope.security.proxy import removeSecurityProxy

=== modified file 'lib/lp/code/browser/tests/test_branch.py'
--- lib/lp/code/browser/tests/test_branch.py	2017-05-08 11:38:20 +0000
+++ lib/lp/code/browser/tests/test_branch.py	2017-10-04 01:26:22 +0000
@@ -3,6 +3,8 @@
 
 """Unit tests for BranchView."""
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 __metaclass__ = type
 
 from datetime import datetime

=== modified file 'lib/lp/code/browser/tests/test_branchlisting.py'
--- lib/lp/code/browser/tests/test_branchlisting.py	2017-06-15 01:02:11 +0000
+++ lib/lp/code/browser/tests/test_branchlisting.py	2017-10-04 01:26:22 +0000
@@ -3,6 +3,8 @@
 
 """Tests for branch listing."""
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 __metaclass__ = type
 
 from datetime import timedelta
@@ -78,7 +80,7 @@
                                                  view_name='+branches'):
         # The Javascript to wire up the ajax batch navigation behaviour is
         # correctly hidden behind a feature flag.
-        flags = {u"ajax.batch_navigator.enabled": u"true"}
+        flags = {"ajax.batch_navigator.enabled": "true"}
         with FeatureFixture(flags):
             view = create_initialized_view(
                 context, name=view_name, rootsite='code', principal=user)

=== modified file 'lib/lp/code/browser/tests/test_branchmergeproposal.py'
--- lib/lp/code/browser/tests/test_branchmergeproposal.py	2017-05-24 12:04:18 +0000
+++ lib/lp/code/browser/tests/test_branchmergeproposal.py	2017-10-04 01:26:22 +0000
@@ -3,6 +3,8 @@
 
 """Unit tests for BranchMergeProposals."""
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 __metaclass__ = type
 
 from datetime import (
@@ -1365,8 +1367,8 @@
 
     def test_preview_diff_all_chars(self):
         """preview_diff should work on diffs containing all possible bytes."""
-        text = ''.join(chr(x) for x in range(255))
-        diff_bytes = ''.join(unified_diff('', text))
+        text = b''.join(chr(x) for x in range(255))
+        diff_bytes = b''.join(unified_diff(b'', text))
         self.setPreviewDiff(diff_bytes)
         transaction.commit()
         view = create_initialized_view(self.bmp, '+index')
@@ -1377,8 +1379,8 @@
     def test_preview_diff_timeout(self):
         # The preview_diff will recover from a timeout set to get the
         # librarian content.
-        text = ''.join(chr(x) for x in range(255))
-        diff_bytes = ''.join(unified_diff('', text))
+        text = b''.join(chr(x) for x in range(255))
+        diff_bytes = b''.join(unified_diff(b'', text))
         preview_diff = self.setPreviewDiff(diff_bytes)
         transaction.commit()
 
@@ -1395,7 +1397,7 @@
 
     def setPreviewDiff(self, preview_diff_bytes):
         return PreviewDiff.create(
-            self.bmp, preview_diff_bytes, u'a', u'b', None, u'')
+            self.bmp, preview_diff_bytes, 'a', 'b', None, '')
 
     def test_linked_bugtasks_excludes_mutual_bugs(self):
         """List bugs that are linked to the source only."""
@@ -1453,7 +1455,7 @@
                 old_revision=revisions[1].revision.getLefthandParent(),
                 new_revision=revisions[3].revision)
         self.useContext(feature_flags())
-        set_feature_flag(u'code.incremental_diffs.enabled', u'enabled')
+        set_feature_flag('code.incremental_diffs.enabled', 'enabled')
         view = create_initialized_view(bmp, '+index')
         comments = view.conversation.comments
         self.assertEqual(
@@ -1486,12 +1488,12 @@
             date_created=review_date)
         self.useFixture(GitHostingFixture(log=[
             {
-                u'sha1': unicode(hashlib.sha1(b'0').hexdigest()),
-                u'message': u'0',
-                u'author': {
-                    u'name': author.display_name,
-                    u'email': author_email,
-                    u'time': int((commit_date - epoch).total_seconds()),
+                'sha1': unicode(hashlib.sha1(b'0').hexdigest()),
+                'message': '0',
+                'author': {
+                    'name': author.display_name,
+                    'email': author_email,
+                    'time': int((commit_date - epoch).total_seconds()),
                     },
                 }
             ]))
@@ -1551,7 +1553,7 @@
         # subscribed to events relating to the merge proposal.
         bmp = self.factory.makeBranchMergeProposal()
         self.useContext(feature_flags())
-        set_feature_flag(u'longpoll.merge_proposals.enabled', u'enabled')
+        set_feature_flag('longpoll.merge_proposals.enabled', 'enabled')
         view = create_initialized_view(bmp, '+index', current_request=True)
         cache = IJSONRequestCache(view.request)
         self.assertIn("longpoll", cache.objects)
@@ -1582,12 +1584,12 @@
         commit_date = datetime(2015, 1, 1, tzinfo=pytz.UTC)
         self.useFixture(GitHostingFixture(log=[
             {
-                u'sha1': sha1,
-                u'message': u'Sample message',
-                u'author': {
-                    u'name': 'Example Person',
-                    u'email': 'person@xxxxxxxxxxx',
-                    u'time': int((commit_date - epoch).total_seconds()),
+                'sha1': sha1,
+                'message': 'Sample message',
+                'author': {
+                    'name': 'Example Person',
+                    'email': 'person@xxxxxxxxxxx',
+                    'time': int((commit_date - epoch).total_seconds()),
                     },
                 }
             ]))
@@ -1891,7 +1893,7 @@
 
     def test_nonascii_in_attachment_renders(self):
         # The view should render without errors.
-        comment = self._makeCommentFromEmailWithAttachment('\xe2\x98\x95')
+        comment = self._makeCommentFromEmailWithAttachment(b'\xe2\x98\x95')
         # Need to commit in order to read the diff out of the librarian.
         transaction.commit()
         view = create_initialized_view(comment, '+comment-body')
@@ -1899,12 +1901,12 @@
 
     def test_nonascii_in_attachment_decoded(self):
         # The diff_text should be a unicode string.
-        comment = self._makeCommentFromEmailWithAttachment('\xe2\x98\x95')
+        comment = self._makeCommentFromEmailWithAttachment(b'\xe2\x98\x95')
         # Need to commit in order to read the diff out of the librarian.
         transaction.commit()
         view = create_initialized_view(comment, '+comment-body')
         [diff_attachment] = view.comment.display_attachments
-        self.assertEqual(u'\u2615', diff_attachment.diff_text)
+        self.assertEqual('\u2615', diff_attachment.diff_text)
 
 
 class TestBranchMergeCandidateView(TestCaseWithFactory):
@@ -1960,7 +1962,7 @@
         diff = self.factory.makeDiff()
         bmp.generateIncrementalDiff(parent, revision, diff)
         self.useContext(feature_flags())
-        set_feature_flag(u'code.incremental_diffs.enabled', u'enabled')
+        set_feature_flag('code.incremental_diffs.enabled', 'enabled')
         browser = self.getViewBrowser(bmp)
         assert 'unf_pbasyvpgf' in browser.contents
 
@@ -1970,7 +1972,7 @@
         # automatically. See also
         # lib/lp/code/stories/branches/xx-branchmergeproposals.txt
         self.useContext(feature_flags())
-        set_feature_flag(u'longpoll.merge_proposals.enabled', u'enabled')
+        set_feature_flag('longpoll.merge_proposals.enabled', 'enabled')
         bmp = self.factory.makeBranchMergeProposal()
         browser = self.getViewBrowser(bmp)
         self.assertIn(

=== modified file 'lib/lp/code/browser/tests/test_branchmergeproposallisting.py'
--- lib/lp/code/browser/tests/test_branchmergeproposallisting.py	2015-10-14 12:50:55 +0000
+++ lib/lp/code/browser/tests/test_branchmergeproposallisting.py	2017-10-04 01:26:22 +0000
@@ -1,8 +1,10 @@
-# Copyright 2009-2015 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2017 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Unit tests for BranchMergeProposal listing views."""
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 __metaclass__ = type
 
 from datetime import datetime

=== modified file 'lib/lp/code/browser/tests/test_branchsubscription.py'
--- lib/lp/code/browser/tests/test_branchsubscription.py	2016-11-09 17:18:21 +0000
+++ lib/lp/code/browser/tests/test_branchsubscription.py	2017-10-04 01:26:22 +0000
@@ -1,8 +1,10 @@
-# Copyright 2009-2016 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2017 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Unit tests for BranchSubscriptions."""
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 __metaclass__ = type
 
 from lp.app.enums import InformationType

=== modified file 'lib/lp/code/browser/tests/test_branchtraversal.py'
--- lib/lp/code/browser/tests/test_branchtraversal.py	2012-01-01 02:58:52 +0000
+++ lib/lp/code/browser/tests/test_branchtraversal.py	2017-10-04 01:26:22 +0000
@@ -1,8 +1,10 @@
-# Copyright 2009 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2017 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Tests for branch traversal."""
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 from zope.component import getUtility
 from zope.publisher.interfaces import NotFound
 from zope.security.proxy import removeSecurityProxy

=== modified file 'lib/lp/code/browser/tests/test_breadcrumbs.py'
--- lib/lp/code/browser/tests/test_breadcrumbs.py	2011-08-12 11:37:08 +0000
+++ lib/lp/code/browser/tests/test_breadcrumbs.py	2017-10-04 01:26:22 +0000
@@ -1,6 +1,8 @@
-# Copyright 2010 Canonical Ltd.  This software is licensed under the
+# Copyright 2010-2017 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 __metaclass__ = type
 
 from lp.testing.breadcrumbs import BaseBreadcrumbTestCase

=== modified file 'lib/lp/code/browser/tests/test_codeimport.py'
--- lib/lp/code/browser/tests/test_codeimport.py	2016-10-13 12:43:14 +0000
+++ lib/lp/code/browser/tests/test_codeimport.py	2017-10-04 01:26:22 +0000
@@ -1,8 +1,10 @@
-# Copyright 2009-2016 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2017 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Tests for the code import browser code."""
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 __metaclass__ = type
 
 import re

=== modified file 'lib/lp/code/browser/tests/test_codereviewcomment.py'
--- lib/lp/code/browser/tests/test_codereviewcomment.py	2016-01-21 01:56:21 +0000
+++ lib/lp/code/browser/tests/test_codereviewcomment.py	2017-10-04 01:26:22 +0000
@@ -1,8 +1,10 @@
-# Copyright 2009-2015 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2017 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Unit tests for CodeReviewComments."""
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 __metaclass__ = type
 
 from soupmatchers import (
@@ -158,9 +160,9 @@
 
     def test_download_view(self):
         """The download view has the expected contents and header."""
-        comment = self.makeCodeReviewComment(body=u'\u1234')
+        comment = self.makeCodeReviewComment(body='\u1234')
         browser = self.getViewBrowser(comment, view_name='+download')
-        contents = u'\u1234'.encode('utf-8')
+        contents = '\u1234'.encode('utf-8')
         self.assertEqual(contents, browser.contents)
         self.assertEqual(
             'text/plain;charset=utf-8', browser.headers['Content-type'])
@@ -171,7 +173,7 @@
 
     def test_parent_comment_in_reply(self):
         """The reply view has the expected contents from the parent comment."""
-        contents = u'test-comment'.encode('utf-8')
+        contents = 'test-comment'.encode('utf-8')
         comment = self.makeCodeReviewComment(body=contents)
         browser = self.getViewBrowser(comment, view_name='+reply')
         self.assertIn(contents, browser.contents)

=== modified file 'lib/lp/code/browser/tests/test_codereviewvote.py'
--- lib/lp/code/browser/tests/test_codereviewvote.py	2012-01-01 02:58:52 +0000
+++ lib/lp/code/browser/tests/test_codereviewvote.py	2017-10-04 01:26:22 +0000
@@ -1,8 +1,10 @@
-# Copyright 2009 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2017 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Unit tests for CodeReviewVoteReferences."""
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 __metaclass__ = type
 
 from lp.services.webapp import canonical_url

=== modified file 'lib/lp/code/browser/tests/test_diff.py'
--- lib/lp/code/browser/tests/test_diff.py	2012-01-01 02:58:52 +0000
+++ lib/lp/code/browser/tests/test_diff.py	2017-10-04 01:26:22 +0000
@@ -1,8 +1,10 @@
-# Copyright 2009 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2017 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Unit tests for DiffView."""
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 from lp.code.browser.diff import PreviewDiffFormatterAPI
 from lp.testing import TestCaseWithFactory
 from lp.testing.layers import LaunchpadFunctionalLayer
@@ -14,7 +16,7 @@
 
     def test_empty_conflicts(self):
         """'has conflicts' does not appear if conflicts is empty string."""
-        diff = self.factory.makePreviewDiff(conflicts=u'')
+        diff = self.factory.makePreviewDiff(conflicts='')
         self.assertEqual('', diff.conflicts)
         formatter = PreviewDiffFormatterAPI(diff)
         self.assertNotIn('has conflicts', formatter.link(None))
@@ -28,7 +30,7 @@
 
     def test_with_conflicts(self):
         """'has conflicts' appears if conflicts is a non-empty string."""
-        diff = self.factory.makePreviewDiff(conflicts=u'bork')
+        diff = self.factory.makePreviewDiff(conflicts='bork')
         self.assertEqual('bork', diff.conflicts)
         formatter = PreviewDiffFormatterAPI(diff)
         self.assertIn('has conflicts', formatter.link(None))

=== modified file 'lib/lp/code/browser/tests/test_gitlisting.py'
--- lib/lp/code/browser/tests/test_gitlisting.py	2015-07-13 00:32:12 +0000
+++ lib/lp/code/browser/tests/test_gitlisting.py	2017-10-04 01:26:22 +0000
@@ -1,8 +1,10 @@
-# Copyright 2015 Canonical Ltd.  This software is licensed under the
+# Copyright 2015-2017 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Unit tests for Git listing views."""
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 __metaclass__ = type
 
 from BeautifulSoup import BeautifulSoup
@@ -31,18 +33,18 @@
 
     def test_rendering(self):
         main_repo = self.factory.makeGitRepository(
-            owner=self.owner, target=self.target, name=u"foo")
+            owner=self.owner, target=self.target, name="foo")
         self.factory.makeGitRefs(
             main_repo,
-            paths=[u"refs/heads/master", u"refs/heads/1.0", u"refs/tags/1.1"])
+            paths=["refs/heads/master", "refs/heads/1.0", "refs/tags/1.1"])
 
         other_repo = self.factory.makeGitRepository(
-            owner=self.factory.makePerson(name=u"contributor"),
-            target=self.target, name=u"foo")
-        self.factory.makeGitRefs(other_repo, paths=[u"refs/heads/bug-1234"])
+            owner=self.factory.makePerson(name="contributor"),
+            target=self.target, name="foo")
+        self.factory.makeGitRefs(other_repo, paths=["refs/heads/bug-1234"])
         self.factory.makeGitRepository(
-            owner=self.factory.makePerson(name=u"random"),
-            target=self.target, name=u"bar")
+            owner=self.factory.makePerson(name="random"),
+            target=self.target, name="bar")
 
         with admin_logged_in():
             getUtility(IGitRepositorySet).setDefaultRepository(
@@ -73,7 +75,7 @@
             [link.find(text=True) for link in table.findAll('a')])
         self.assertEndsWith(
             table.find(text="1.0").parent['href'],
-            u"/~foowner/%s/+git/foo/+ref/1.0" % self.target_path)
+            "/~foowner/%s/+git/foo/+ref/1.0" % self.target_path)
 
         # Other repos are listed.
         table = soup.find(
@@ -86,7 +88,7 @@
         self.assertEndsWith(
             table.find(
                 text="lp:~contributor/%s" % self.target_path).parent['href'],
-            u"/~contributor/%s/+git/foo" % self.target_path)
+            "/~contributor/%s/+git/foo" % self.target_path)
 
         # But not their branches.
         self.assertNotIn('bug-1234', content)
@@ -112,8 +114,8 @@
 
     def test_copes_with_no_default(self):
         self.factory.makeGitRepository(
-            owner=self.factory.makePerson(name=u"contributor"),
-            target=self.target, name=u"foo")
+            owner=self.factory.makePerson(name="contributor"),
+            target=self.target, name="foo")
 
         view = create_initialized_view(self.target, '+git')
         self.assertIs(None, view.default_git_repository)
@@ -184,14 +186,14 @@
 
     def test_rendering(self):
         default_repo = self.factory.makeGitRepository(
-            owner=self.owner, target=self.target, name=u"foo")
+            owner=self.owner, target=self.target, name="foo")
         self.factory.makeGitRefs(
             default_repo,
-            paths=[u"refs/heads/master", u"refs/heads/bug-1234"])
+            paths=["refs/heads/master", "refs/heads/bug-1234"])
 
         other_repo = self.factory.makeGitRepository(
-            owner=self.owner, target=self.target, name=u"bar")
-        self.factory.makeGitRefs(other_repo, paths=[u"refs/heads/bug-2468"])
+            owner=self.owner, target=self.target, name="bar")
+        self.factory.makeGitRefs(other_repo, paths=["refs/heads/bug-2468"])
 
         with admin_logged_in():
             getUtility(IGitRepositorySet).setDefaultRepositoryForOwner(
@@ -220,7 +222,7 @@
             [link.find(text=True) for link in table.findAll('a')])
         self.assertEndsWith(
             table.find(text="bug-1234").parent['href'],
-            u"/~dev/%s/+git/foo/+ref/bug-1234" % self.target_path)
+            "/~dev/%s/+git/foo/+ref/bug-1234" % self.target_path)
 
         # Other repos are listed.
         table = soup.find(
@@ -232,14 +234,14 @@
         self.assertEndsWith(
             table.find(
                 text="lp:~dev/%s/+git/bar" % self.target_path).parent['href'],
-            u"/~dev/%s/+git/bar" % self.target_path)
+            "/~dev/%s/+git/bar" % self.target_path)
 
         # But not their branches.
         self.assertNotIn('bug-2468', content)
 
     def test_copes_with_no_default(self):
         self.factory.makeGitRepository(
-            owner=self.owner, target=self.target, name=u"foo")
+            owner=self.owner, target=self.target, name="foo")
 
         view = create_initialized_view(self.owner_target, '+git')
         self.assertIs(None, view.default_git_repository)
@@ -311,9 +313,9 @@
 
     def setUp(self):
         super(TestProductGitListingView, self).setUp()
-        self.owner = self.factory.makePerson(name=u"foowner")
-        self.target = self.factory.makeProduct(name=u"foo", owner=self.owner)
-        self.target_path = u"foo"
+        self.owner = self.factory.makePerson(name="foowner")
+        self.target = self.factory.makeProduct(name="foo", owner=self.owner)
+        self.target_path = "foo"
         self.branch_target = self.target
 
 
@@ -322,9 +324,9 @@
 
     def setUp(self):
         super(TestPersonProductGitListingView, self).setUp()
-        self.owner = self.factory.makePerson(name=u"dev")
-        self.target = self.factory.makeProduct(name=u"foo")
-        self.target_path = u"foo"
+        self.owner = self.factory.makePerson(name="dev")
+        self.target = self.factory.makeProduct(name="foo")
+        self.target_path = "foo"
         self.owner_target = PersonProduct(self.owner, self.target)
         self.branch_target = self.target
 
@@ -334,11 +336,11 @@
 
     def setUp(self):
         super(TestDistributionSourcePackageGitListingView, self).setUp()
-        self.owner = self.factory.makePerson(name=u"foowner")
-        distro = self.factory.makeDistribution(name=u"foo", owner=self.owner)
+        self.owner = self.factory.makePerson(name="foowner")
+        distro = self.factory.makeDistribution(name="foo", owner=self.owner)
         self.target = self.factory.makeDistributionSourcePackage(
-            distribution=distro, sourcepackagename=u"bar")
-        self.target_path = u"foo/+source/bar"
+            distribution=distro, sourcepackagename="bar")
+        self.target_path = "foo/+source/bar"
         self.factory.makeDistroSeries(distribution=distro)
         self.branch_target = self.target.development_version
 
@@ -348,11 +350,11 @@
 
     def setUp(self):
         super(TestPersonDistributionSourcePackageGitListingView, self).setUp()
-        self.owner = self.factory.makePerson(name=u"dev")
-        distro = self.factory.makeDistribution(name=u"foo", owner=self.owner)
+        self.owner = self.factory.makePerson(name="dev")
+        distro = self.factory.makeDistribution(name="foo", owner=self.owner)
         self.target = self.factory.makeDistributionSourcePackage(
-            distribution=distro, sourcepackagename=u"bar")
-        self.target_path = u"foo/+source/bar"
+            distribution=distro, sourcepackagename="bar")
+        self.target_path = "foo/+source/bar"
         self.owner_target = PersonDistributionSourcePackage(
             self.owner, self.target)
         self.factory.makeDistroSeries(distribution=distro)
@@ -376,14 +378,14 @@
 
     def test_rendering(self):
         some_repo = self.factory.makeGitRepository(
-            owner=self.owner, target=self.target, name=u"foo")
+            owner=self.owner, target=self.target, name="foo")
         self.factory.makeGitRefs(
             some_repo,
-            paths=[u"refs/heads/master", u"refs/heads/bug-1234"])
+            paths=["refs/heads/master", "refs/heads/bug-1234"])
 
         other_repo = self.factory.makeGitRepository(
-            owner=self.owner, target=self.target, name=u"bar")
-        self.factory.makeGitRefs(other_repo, paths=[u"refs/heads/bug-2468"])
+            owner=self.owner, target=self.target, name="bar")
+        self.factory.makeGitRefs(other_repo, paths=["refs/heads/bug-2468"])
 
         view = create_initialized_view(self.context, '+git')
         self.assertIs(None, view.default_git_repository)

=== modified file 'lib/lp/code/browser/tests/test_gitref.py'
--- lib/lp/code/browser/tests/test_gitref.py	2016-11-11 14:57:42 +0000
+++ lib/lp/code/browser/tests/test_gitref.py	2017-10-04 01:26:22 +0000
@@ -1,8 +1,10 @@
-# Copyright 2015-2016 Canonical Ltd.  This software is licensed under the
+# Copyright 2015-2017 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Unit tests for GitRefView."""
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 __metaclass__ = type
 
 from datetime import datetime
@@ -52,11 +54,11 @@
         repository = self.factory.makeGitRepository(
             owner=self.factory.makePerson(name="person"),
             target=self.factory.makeProduct(name="target"),
-            name=u"git")
+            name="git")
         getUtility(IGitRepositorySet).setDefaultRepositoryForOwner(
             repository.owner, repository.target, repository, repository.owner)
         [ref] = self.factory.makeGitRefs(
-            repository=repository, paths=[u"refs/heads/master"])
+            repository=repository, paths=["refs/heads/master"])
         view = create_view(ref, "+index")
         # To test the breadcrumbs we need a correct traversal stack.
         view.request.traversed_objects = [repository, ref, view]
@@ -86,7 +88,7 @@
                         text=re.compile(r'\smaster\s')))))
 
     def test_clone_instructions(self):
-        [ref] = self.factory.makeGitRefs(paths=[u"refs/heads/branch"])
+        [ref] = self.factory.makeGitRefs(paths=["refs/heads/branch"])
         text = self.getMainText(ref, "+index", user=ref.owner)
         self.assertTextMatchesExpressionIgnoreWhitespace(r"""
             git clone -b branch https://.*
@@ -102,20 +104,20 @@
             datetime(2015, 1, day + 1, tzinfo=pytz.UTC) for day in range(5)]
         return [
             {
-                u"sha1": unicode(hashlib.sha1(str(i)).hexdigest()),
-                u"message": u"Commit %d" % i,
-                u"author": {
-                    u"name": authors[i].display_name,
-                    u"email": author_emails[i],
-                    u"time": int((dates[i] - epoch).total_seconds()),
-                    },
-                u"committer": {
-                    u"name": authors[i].display_name,
-                    u"email": author_emails[i],
-                    u"time": int((dates[i] - epoch).total_seconds()),
-                    },
-                u"parents": [unicode(hashlib.sha1(str(i - 1)).hexdigest())],
-                u"tree": unicode(hashlib.sha1("").hexdigest()),
+                "sha1": unicode(hashlib.sha1(str(i)).hexdigest()),
+                "message": "Commit %d" % i,
+                "author": {
+                    "name": authors[i].display_name,
+                    "email": author_emails[i],
+                    "time": int((dates[i] - epoch).total_seconds()),
+                    },
+                "committer": {
+                    "name": authors[i].display_name,
+                    "email": author_emails[i],
+                    "time": int((dates[i] - epoch).total_seconds()),
+                    },
+                "parents": [unicode(hashlib.sha1(str(i - 1)).hexdigest())],
+                "tree": unicode(hashlib.sha1("").hexdigest()),
                 }
             for i in range(5)]
 
@@ -133,7 +135,7 @@
             JobRunner([job]).runAll()
 
     def test_recent_commits(self):
-        [ref] = self.factory.makeGitRefs(paths=[u"refs/heads/branch"])
+        [ref] = self.factory.makeGitRefs(paths=["refs/heads/branch"])
         log = self.makeCommitLog()
         self.hosting_fixture.getLog.result = list(reversed(log))
         self.scanRef(ref, log[-1])
@@ -153,7 +155,7 @@
             expected_urls, [detail.a["href"] for detail in details])
 
     def test_recent_commits_with_merge(self):
-        [ref] = self.factory.makeGitRefs(paths=[u"refs/heads/branch"])
+        [ref] = self.factory.makeGitRefs(paths=["refs/heads/branch"])
         log = self.makeCommitLog()
         self.hosting_fixture.getLog.result = list(reversed(log))
         self.scanRef(ref, log[-1])
@@ -179,7 +181,7 @@
             [link["href"] for link in details[5].findAll("a")])
 
     def test_recent_commits_with_merge_from_deleted_ref(self):
-        [ref] = self.factory.makeGitRefs(paths=[u"refs/heads/branch"])
+        [ref] = self.factory.makeGitRefs(paths=["refs/heads/branch"])
         log = self.makeCommitLog()
         self.hosting_fixture.getLog.result = list(reversed(log))
         self.scanRef(ref, log[-1])
@@ -206,7 +208,7 @@
             [link["href"] for link in details[5].findAll("a")])
 
     def test_all_commits_link(self):
-        [ref] = self.factory.makeGitRefs(paths=[u"refs/heads/branch"])
+        [ref] = self.factory.makeGitRefs(paths=["refs/heads/branch"])
         log = self.makeCommitLog()
         self.hosting_fixture.getLog.result = list(reversed(log))
         self.scanRef(ref, log[-1])

=== modified file 'lib/lp/code/browser/tests/test_gitrepository.py'
--- lib/lp/code/browser/tests/test_gitrepository.py	2016-11-17 23:16:12 +0000
+++ lib/lp/code/browser/tests/test_gitrepository.py	2017-10-04 01:26:22 +0000
@@ -1,8 +1,10 @@
-# Copyright 2015-2016 Canonical Ltd.  This software is licensed under the
+# Copyright 2015-2017 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Unit tests for GitRepositoryView."""
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 __metaclass__ = type
 
 from datetime import datetime
@@ -327,7 +329,7 @@
         self.factory.makeAccessPolicyGrant(
             policy=ap, grantee=subscriber, grantor=project.owner)
         repository = self.factory.makeGitRepository(
-            target=project, owner=owner, name=u"repo",
+            target=project, owner=owner, name="repo",
             information_type=InformationType.USERDATA)
         with person_logged_in(owner):
             self.factory.makeGitSubscription(
@@ -390,7 +392,7 @@
                 naked_ref.author_date = now
                 naked_ref.committer = self.makeRevisionAuthor()
                 naked_ref.committer_date = now
-                naked_ref.commit_message = u"something"
+                naked_ref.commit_message = "something"
 
         recorder1, recorder2 = record_two_runs(
             lambda: self.getMainText(repository, "+index"), create_ref, 10)
@@ -670,13 +672,13 @@
         # The name of a repository can be changed via the UI by an
         # authorised user.
         person = self.factory.makePerson()
-        repository = self.factory.makeGitRepository(owner=person, name=u"foo")
+        repository = self.factory.makeGitRepository(owner=person, name="foo")
         browser = self.getUserBrowser(
             canonical_url(repository) + "/+edit", user=person)
-        browser.getControl(name="field.name").value = u"bar"
+        browser.getControl(name="field.name").value = "bar"
         browser.getControl("Change Git Repository").click()
         with person_logged_in(person):
-            self.assertEqual(u"bar", repository.name)
+            self.assertEqual("bar", repository.name)
 
     def test_change_owner(self):
         # An authorised user can change the owner to a team they're a member
@@ -762,18 +764,18 @@
         repository = self.factory.makeGitRepository(owner=person)
         master, new = self.factory.makeGitRefs(
             repository=repository,
-            paths=[u"refs/heads/master", u"refs/heads/new"])
-        removeSecurityProxy(repository)._default_branch = u"refs/heads/master"
+            paths=["refs/heads/master", "refs/heads/new"])
+        removeSecurityProxy(repository)._default_branch = "refs/heads/master"
         browser = self.getUserBrowser(
             canonical_url(repository) + "/+edit", user=person)
-        browser.getControl(name="field.default_branch").value = u"new"
+        browser.getControl(name="field.default_branch").value = "new"
         browser.getControl("Change Git Repository").click()
         with person_logged_in(person):
             self.assertEqual(
                 [((repository.getInternalPath(),),
-                 {u"default_branch": u"refs/heads/new"})],
+                 {"default_branch": "refs/heads/new"})],
                 hosting_fixture.setProperties.calls)
-            self.assertEqual(u"refs/heads/new", repository.default_branch)
+            self.assertEqual("refs/heads/new", repository.default_branch)
 
     def test_change_default_branch_nonexistent(self):
         # Trying to change the default branch to one that doesn't exist
@@ -781,8 +783,8 @@
         person = self.factory.makePerson()
         repository = self.factory.makeGitRepository(owner=person)
         [master] = self.factory.makeGitRefs(
-            repository=repository, paths=[u"refs/heads/master"])
-        removeSecurityProxy(repository)._default_branch = u"refs/heads/master"
+            repository=repository, paths=["refs/heads/master"])
+        removeSecurityProxy(repository)._default_branch = "refs/heads/master"
         form = {
             "field.default_branch": "refs/heads/new",
             "field.actions.change": "Change Git Repository",
@@ -794,7 +796,7 @@
             ["This repository does not contain a reference named "
              "'refs/heads/new'."],
             view.errors)
-        self.assertEqual(u"refs/heads/master", repository.default_branch)
+        self.assertEqual("refs/heads/master", repository.default_branch)
 
 
 class TestGitRepositoryEditViewInformationTypes(TestCaseWithFactory):
@@ -869,7 +871,7 @@
     layer = DatabaseFunctionalLayer
 
     def test_render(self):
-        diff = u"A fake diff\n"
+        diff = "A fake diff\n"
         hosting_fixture = self.useFixture(GitHostingFixture(
             diff={"patch": diff}))
         person = self.factory.makePerson()
@@ -891,7 +893,7 @@
     def test_security(self):
         # A user who can see a private repository can fetch diffs from it,
         # but other users cannot.
-        diff = u"A fake diff\n"
+        diff = "A fake diff\n"
         self.useFixture(GitHostingFixture(diff={"patch": diff}))
         person = self.factory.makePerson()
         project = self.factory.makeProduct(

=== modified file 'lib/lp/code/browser/tests/test_gitsubscription.py'
--- lib/lp/code/browser/tests/test_gitsubscription.py	2016-11-09 17:18:21 +0000
+++ lib/lp/code/browser/tests/test_gitsubscription.py	2017-10-04 01:26:22 +0000
@@ -1,8 +1,10 @@
-# Copyright 2015-2016 Canonical Ltd.  This software is licensed under the
+# Copyright 2015-2017 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Unit tests for GitSubscriptions."""
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 __metaclass__ = type
 
 from urllib import urlencode

=== modified file 'lib/lp/code/browser/tests/test_product.py'
--- lib/lp/code/browser/tests/test_product.py	2015-06-04 08:50:04 +0000
+++ lib/lp/code/browser/tests/test_product.py	2017-10-04 01:26:22 +0000
@@ -1,8 +1,10 @@
-# Copyright 2009-2015 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2017 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Tests for the product view classes and templates."""
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 __metaclass__ = type
 
 from datetime import (

=== modified file 'lib/lp/code/browser/tests/test_revisionauthor.py'
--- lib/lp/code/browser/tests/test_revisionauthor.py	2012-01-01 02:58:52 +0000
+++ lib/lp/code/browser/tests/test_revisionauthor.py	2017-10-04 01:26:22 +0000
@@ -1,8 +1,10 @@
-# Copyright 2011 Canonical Ltd.  This software is licensed under the
+# Copyright 2011-2017 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Tests related to `RevisionAuthor`."""
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 __metaclass__ = type
 
 from lp.app.browser.tales import (

=== modified file 'lib/lp/code/browser/tests/test_sourcepackagerecipe.py'
--- lib/lp/code/browser/tests/test_sourcepackagerecipe.py	2017-06-16 10:29:14 +0000
+++ lib/lp/code/browser/tests/test_sourcepackagerecipe.py	2017-10-04 01:26:22 +0000
@@ -3,9 +3,10 @@
 
 """Tests for the source package recipe view classes and templates."""
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 __metaclass__ = type
 
-
 from datetime import (
     datetime,
     timedelta,
@@ -91,7 +92,7 @@
     def test_canonical_url(self):
         owner = self.factory.makePerson(name='recipe-owner')
         recipe = self.factory.makeSourcePackageRecipe(
-            owner=owner, name=u'recipe-name')
+            owner=owner, name='recipe-name')
         self.assertEqual(
             'http://code.launchpad.dev/~recipe-owner/+recipe/recipe-name',
             canonical_url(recipe))
@@ -261,10 +262,10 @@
         """Create and return a specific recipe."""
         chocolate = self.factory.makeProduct(name='chocolate')
         cake_branch = self.makeBranch(
-            owner=self.chef, name=u'cake', target=chocolate)
+            owner=self.chef, name='cake', target=chocolate)
         return self.factory.makeSourcePackageRecipe(
-            owner=self.chef, distroseries=self.squirrel, name=u'cake_recipe',
-            description=u'This recipe builds a foo for distro bar, with my'
+            owner=self.chef, distroseries=self.squirrel, name='cake_recipe',
+            description='This recipe builds a foo for distro bar, with my'
             ' Secret Squirrel changes.', branches=[cake_branch],
             daily_build_archive=self.ppa, **kwargs)
 
@@ -277,8 +278,7 @@
         # If the initial name exists, a generator is used to find an unused
         # name by appending a numbered suffix on the end.
         owner = self.factory.makePerson()
-        self.factory.makeSourcePackageRecipe(
-            owner=owner, name=u'widget-daily')
+        self.factory.makeSourcePackageRecipe(owner=owner, name='widget-daily')
         widget = self.factory.makeProduct(name='widget')
         branch = self.makeBranch(target=widget)
         with person_logged_in(owner):
@@ -380,7 +380,7 @@
         # not helpful.
         owner = self.factory.makePerson()
         repository = self.factory.makeGitRepository(
-            owner=owner, target=owner, name=u'widget')
+            owner=owner, target=owner, name='widget')
         with person_logged_in(repository.owner):
             view = create_initialized_view(repository, '+new-recipe')
         self.assertThat('widget-daily', Equals(view.initial_values['name']))
@@ -395,7 +395,7 @@
         product = self.factory.makeProduct(
             name='ratatouille', displayname='Ratatouille')
         branch = self.makeBranch(
-            owner=self.chef, target=product, name=u'veggies')
+            owner=self.chef, target=product, name='veggies')
 
         browser = self.getViewBrowser(branch, no_login=True)
         self.assertRaises(
@@ -461,7 +461,7 @@
         browser.getControl('Create Recipe').click()
 
         login(ANONYMOUS)
-        recipe = team.getRecipe(u'daily')
+        recipe = team.getRecipe('daily')
         self.assertEqual(team, recipe.owner)
         self.assertEqual('daily', recipe.name)
 
@@ -498,7 +498,7 @@
         product = self.factory.makeProduct(
             name='ratatouille', displayname='Ratatouille')
         branch = self.makeBranch(
-            owner=self.chef, target=product, name=u'veggies')
+            owner=self.chef, target=product, name='veggies')
         browser = self.getViewBrowser(branch, '+new-recipe', user=self.chef)
         browser.getControl('Description').value = 'Make some food!'
         browser.getControl('Recipe text').value = (
@@ -513,7 +513,7 @@
             product = self.factory.makeProduct(
                 name='ratatouille', displayname='Ratatouille')
             branch = self.makeBranch(
-                owner=self.chef, target=product, name=u'veggies')
+                owner=self.chef, target=product, name='veggies')
         browser = self.getViewBrowser(branch, '+new-recipe', user=self.chef)
         browser.getControl(name='field.name').value = 'daily'
         browser.getControl('Description').value = 'Make some food!'
@@ -524,8 +524,8 @@
     def test_create_recipe_usage(self):
         # The error for a recipe with invalid instruction parameters should
         # include instruction usage.
-        branch = self.makeBranch(name=u'veggies')
-        self.makeBranch(name=u'packaging')
+        branch = self.makeBranch(name='veggies')
+        self.makeBranch(name='packaging')
 
         browser = self.createRecipe(
             self.getMinimalRecipeText(branch) + "merge\n", branch=branch)
@@ -564,7 +564,7 @@
         product = self.factory.makeProduct(
             name='ratatouille', displayname='Ratatouille')
         branch = self.makeBranch(
-            owner=self.chef, target=product, name=u'veggies')
+            owner=self.chef, target=product, name='veggies')
         recipe = self.getMinimalRecipeText(branch)
         recipe += 'nest packaging foo debian'
         browser = self.createRecipe(recipe, branch)
@@ -578,7 +578,7 @@
         product = self.factory.makeProduct(
             name='ratatouille', displayname='Ratatouille')
         branch = self.makeBranch(
-            owner=self.chef, target=product, name=u'veggies')
+            owner=self.chef, target=product, name='veggies')
 
         with recipe_parser_newest_version(145.115):
             recipe = re.sub(
@@ -599,7 +599,7 @@
         product = self.factory.makeProduct(
             name='ratatouille', displayname='Ratatouille')
         branch = self.makeBranch(
-            owner=self.chef, target=product, name=u'veggies')
+            owner=self.chef, target=product, name='veggies')
 
         # A new recipe can be created from the branch page.
         browser = self.getUserBrowser(canonical_url(branch), user=self.chef)
@@ -859,7 +859,7 @@
         product = self.factory.makeProduct(
             name='ratatouille', displayname='Ratatouille')
         repository = self.factory.makeGitRepository(
-            owner=self.chef, target=product, name=u'veggies')
+            owner=self.chef, target=product, name='veggies')
         self.factory.makeDistributionSourcePackage(
             sourcepackagename='ratatouille')
         return repository
@@ -877,12 +877,12 @@
         product = self.factory.makeProduct(
             name='ratatouille', displayname='Ratatouille')
         veggie_branch = self.makeBranch(
-            owner=self.chef, target=product, name=u'veggies')
+            owner=self.chef, target=product, name='veggies')
         meat_branch = self.makeBranch(
-            owner=self.chef, target=product, name=u'meat')
+            owner=self.chef, target=product, name='meat')
         recipe = self.factory.makeSourcePackageRecipe(
             owner=self.chef, registrant=self.chef,
-            name=u'things', description=u'This is a recipe',
+            name='things', description='This is a recipe',
             distroseries=self.squirrel, branches=[veggie_branch],
             daily_build_archive=self.ppa)
         self.factory.makeArchive(
@@ -921,7 +921,7 @@
         view = SourcePackageRecipeEditView(recipe, LaunchpadTestRequest())
         view.initialize()
         view.request_action.success({
-            'name': u'fings',
+            'name': 'fings',
             'recipe_text': recipe.recipe_text,
             'distroseries': recipe.distroseries})
         self.assertSqlAttributeEqualsDate(
@@ -934,12 +934,12 @@
         product = self.factory.makeProduct(
             name='ratatouille', displayname='Ratatouille')
         veggie_branch = self.makeBranch(
-            owner=self.chef, target=product, name=u'veggies')
+            owner=self.chef, target=product, name='veggies')
         meat_branch = self.makeBranch(
-            owner=self.chef, target=product, name=u'meat')
+            owner=self.chef, target=product, name='meat')
         recipe = self.factory.makeSourcePackageRecipe(
             owner=self.chef, registrant=self.chef,
-            name=u'things', description=u'This is a recipe',
+            name='things', description='This is a recipe',
             distroseries=self.squirrel, branches=[veggie_branch],
             daily_build_archive=self.ppa)
 
@@ -979,10 +979,10 @@
         product = self.factory.makeProduct(
             name='ratatouille', displayname='Ratatouille')
         veggie_branch = self.makeBranch(
-            owner=self.chef, target=product, name=u'veggies')
+            owner=self.chef, target=product, name='veggies')
         recipe = self.factory.makeSourcePackageRecipe(
             owner=self.chef, registrant=self.chef,
-            name=u'things', description=u'This is a recipe',
+            name='things', description='This is a recipe',
             distroseries=self.squirrel, branches=[veggie_branch])
 
         browser = self.getUserBrowser(canonical_url(recipe), user=self.chef)
@@ -1004,10 +1004,10 @@
         product = self.factory.makeProduct(
             name='ratatouille', displayname='Ratatouille')
         veggie_branch = self.makeBranch(
-            owner=self.chef, target=product, name=u'veggies')
+            owner=self.chef, target=product, name='veggies')
         recipe = self.factory.makeSourcePackageRecipe(
             owner=self.chef, registrant=self.chef,
-            name=u'things', description=u'This is a recipe',
+            name='things', description='This is a recipe',
             distroseries=self.squirrel, branches=[veggie_branch])
 
         new_recipe_text = re.sub(
@@ -1031,16 +1031,16 @@
         product = self.factory.makeProduct(
             name='ratatouille', displayname='Ratatouille')
         veggie_branch = self.makeBranch(
-            owner=self.chef, target=product, name=u'veggies')
+            owner=self.chef, target=product, name='veggies')
         meat_branch = self.makeBranch(
-            owner=self.chef, target=product, name=u'meat')
+            owner=self.chef, target=product, name='meat')
         recipe = self.factory.makeSourcePackageRecipe(
             owner=self.chef, registrant=self.chef,
-            name=u'things', description=u'This is a recipe',
+            name='things', description='This is a recipe',
             distroseries=self.squirrel, branches=[veggie_branch])
         self.factory.makeSourcePackageRecipe(
             owner=self.chef, registrant=self.chef,
-            name=u'fings', description=u'This is a recipe',
+            name='fings', description='This is a recipe',
             distroseries=self.squirrel, branches=[veggie_branch])
 
         recipe_text = self.getMinimalRecipeText(meat_branch)
@@ -1717,7 +1717,7 @@
             owner=self.user)
         branch = self.makeBranch()
         recipe = self.factory.makeSourcePackageRecipe(
-            owner=self.user, name=u'my-recipe', branches=[branch])
+            owner=self.user, name='my-recipe', branches=[branch])
         distro_series = self.factory.makeDistroSeries(
             name='squirrel', distribution=archive.distribution)
         removeSecurityProxy(distro_series).nominatedarchindep = (
@@ -1999,7 +1999,7 @@
         recipe = self.factory.makeSourcePackageRecipe(recipe=recipe_text)
         naked_data = removeSecurityProxy(recipe)._recipe_data
         nest_instruction = list(naked_data.instructions)[0]
-        nest_instruction.directory = u'.'
+        nest_instruction.directory = '.'
         return recipe
 
     def test_recipe_is_broken(self):

=== modified file 'lib/lp/code/browser/tests/test_sourcepackagerecipebuild.py'
--- lib/lp/code/browser/tests/test_sourcepackagerecipebuild.py	2017-05-08 11:38:20 +0000
+++ lib/lp/code/browser/tests/test_sourcepackagerecipebuild.py	2017-10-04 01:26:22 +0000
@@ -1,7 +1,10 @@
 # Copyright 2010-2017 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
+
 """Tests for the source package recipe view classes and templates."""
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 __metaclass__ = type
 
 from fixtures import FakeLogger
@@ -77,8 +80,8 @@
         cake_branch = self.factory.makeProductBranch(
             owner=self.chef, name='cake', product=chocolate)
         recipe = self.factory.makeSourcePackageRecipe(
-            owner=self.chef, distroseries=self.squirrel, name=u'cake_recipe',
-            description=u'This recipe builds a foo for disto bar, with my'
+            owner=self.chef, distroseries=self.squirrel, name='cake_recipe',
+            description='This recipe builds a foo for distro bar, with my'
             ' Secret Squirrel changes.', branches=[cake_branch],
             daily_build_archive=self.ppa)
         build = self.factory.makeSourcePackageRecipeBuild(

=== modified file 'lib/lp/code/browser/tests/test_sourcepackagerecipelisting.py'
--- lib/lp/code/browser/tests/test_sourcepackagerecipelisting.py	2015-10-19 10:56:16 +0000
+++ lib/lp/code/browser/tests/test_sourcepackagerecipelisting.py	2017-10-04 01:26:22 +0000
@@ -1,11 +1,12 @@
-# Copyright 2010-2015 Canonical Ltd.  This software is licensed under the
+# Copyright 2010-2017 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Tests for sourcepackagerecipe listings."""
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 __metaclass__ = type
 
-
 from lp.testing import (
     BrowserTestCase,
     person_logged_in,

=== modified file 'lib/lp/code/browser/tests/test_tales.py'
--- lib/lp/code/browser/tests/test_tales.py	2016-01-12 15:27:50 +0000
+++ lib/lp/code/browser/tests/test_tales.py	2017-10-04 01:26:22 +0000
@@ -1,8 +1,10 @@
-# Copyright 2009-2015 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2017 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Tests for the tales formatters."""
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 __metaclass__ = type
 
 from difflib import unified_diff
@@ -41,7 +43,7 @@
         else:
             content = ''
         preview = bmp.updatePreviewDiff(
-            content, u'rev-a', u'rev-b', conflicts=conflicts)
+            content, 'rev-a', 'rev-b', conflicts=conflicts)
         bmp.source_branch.last_scanned_id = preview.source_revision_id
         bmp.target_branch.last_scanned_id = preview.target_revision_id
         # Update the values directly sidestepping the security.
@@ -68,13 +70,13 @@
     def test_creation_method(self):
         # Just confirm that our helpers do what they say.
         preview = self._createPreviewDiff(
-            12, 45, 23, u'conflicts', {'filename': (3, 2)})
+            12, 45, 23, 'conflicts', {'filename': (3, 2)})
         self.assertEqual(12, preview.diff_lines_count)
         self.assertEqual(45, preview.added_lines_count)
         self.assertEqual(23, preview.removed_lines_count)
         self.assertEqual(False, preview.stale)
         self.assertEqual(True, self._createStalePreviewDiff().stale)
-        self.assertEqual(u'conflicts', preview.conflicts)
+        self.assertEqual('conflicts', preview.conflicts)
         self.assertEqual({'filename': (3, 2)}, preview.diffstat)
 
     def test_fmt_no_diff(self):
@@ -151,7 +153,7 @@
 
     def test_fmt_simple_conflicts(self):
         # Conflicts are indicated using text in the link.
-        preview = self._createPreviewDiff(10, 2, 3, u'conflicts')
+        preview = self._createPreviewDiff(10, 2, 3, 'conflicts')
         self.assertEqual(
             '<a href="%s/+files/preview.diff" class="diff-link">'
             '10 lines (+2/-3) (has conflicts)</a>'
@@ -188,7 +190,7 @@
         diffstat = dict(
             (self.factory.getUniqueString(), (2, 3)) for x in range(23))
         preview = self._createStalePreviewDiff(
-            500, 89, 340, u'conflicts', diffstat=diffstat)
+            500, 89, 340, 'conflicts', diffstat=diffstat)
         expected_diffstat = '<br/>'.join(
             '%s (+2/-3)' % path for path in sorted(diffstat))
         self.assertEqual(

=== modified file 'lib/lp/code/browser/tests/test_vcslisting.py'
--- lib/lp/code/browser/tests/test_vcslisting.py	2015-06-12 06:34:19 +0000
+++ lib/lp/code/browser/tests/test_vcslisting.py	2017-10-04 01:26:22 +0000
@@ -1,8 +1,10 @@
-# Copyright 2009-2015 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2017 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Tests for the product view classes and templates."""
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 __metaclass__ = type
 
 from zope.publisher.interfaces import NotFound

=== modified file 'lib/lp/code/browser/tests/test_views.py'
--- lib/lp/code/browser/tests/test_views.py	2011-12-28 17:03:06 +0000
+++ lib/lp/code/browser/tests/test_views.py	2017-10-04 01:26:22 +0000
@@ -1,9 +1,9 @@
-# Copyright 2009 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2017 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
-"""
-Run the view tests.
-"""
+"""Run the view tests."""
+
+from __future__ import absolute_import, print_function, unicode_literals
 
 import logging
 import os


Follow ups