← Back to team overview

launchpad-reviewers team mailing list archive

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

 

Colin Watson has proposed merging lp:~cjwatson/launchpad/archivepublisher-tests-future-imports into lp:launchpad with lp:~cjwatson/launchpad/soyuz-tests-future-imports as a prerequisite.

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

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

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

The contents of files in tarfiles need to remain as bytes, but everything else was easy.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/archivepublisher-tests-future-imports into lp:launchpad.
=== modified file 'lib/lp/archivepublisher/tests/__init__.py'
--- lib/lp/archivepublisher/tests/__init__.py	2010-08-20 20:31:18 +0000
+++ lib/lp/archivepublisher/tests/__init__.py	2018-02-02 11:57:41 +0000
@@ -1,6 +1,8 @@
-# Copyright 2009 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2018 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
+
 import os
 
 

=== modified file 'lib/lp/archivepublisher/tests/test_archivesigningkey.py'
--- lib/lp/archivepublisher/tests/test_archivesigningkey.py	2017-04-29 15:24:32 +0000
+++ lib/lp/archivepublisher/tests/test_archivesigningkey.py	2018-02-02 11:57:41 +0000
@@ -1,8 +1,10 @@
-# Copyright 2016-2017 Canonical Ltd.  This software is licensed under the
+# Copyright 2016-2018 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Test ArchiveSigningKey."""
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 __metaclass__ = type
 
 import os

=== modified file 'lib/lp/archivepublisher/tests/test_config.py'
--- lib/lp/archivepublisher/tests/test_config.py	2016-05-04 14:49:37 +0000
+++ lib/lp/archivepublisher/tests/test_config.py	2018-02-02 11:57:41 +0000
@@ -1,4 +1,4 @@
-# Copyright 2011-2016 Canonical Ltd.  This software is licensed under the
+# Copyright 2011-2018 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Test publisher configs handling.
@@ -6,6 +6,8 @@
 Publisher configuration provides archive-dependent filesystem paths.
 """
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 __metaclass__ = type
 
 import os

=== modified file 'lib/lp/archivepublisher/tests/test_customupload.py'
--- lib/lp/archivepublisher/tests/test_customupload.py	2012-05-28 13:13:53 +0000
+++ lib/lp/archivepublisher/tests/test_customupload.py	2018-02-02 11:57:41 +0000
@@ -1,8 +1,10 @@
-# Copyright 2009-2012 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2018 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Tests for `CustomUploads`."""
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 __metaclass__ = type
 
 

=== modified file 'lib/lp/archivepublisher/tests/test_ddtp_tarball.py'
--- lib/lp/archivepublisher/tests/test_ddtp_tarball.py	2016-06-07 17:07:35 +0000
+++ lib/lp/archivepublisher/tests/test_ddtp_tarball.py	2018-02-02 11:57:41 +0000
@@ -1,4 +1,4 @@
-# Copyright 2012-2016 Canonical Ltd.  This software is licensed under the
+# Copyright 2012-2018 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Test ddtp-tarball custom uploads.
@@ -7,6 +7,8 @@
 tests of ddtp-tarball upload and queue manipulation.
 """
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 import os
 
 from zope.component import getUtility
@@ -57,7 +59,7 @@
     def test_basic(self):
         # Processing a simple correct tar file works.
         self.openArchive("20060728")
-        self.tarfile.add_file("i18n/Translation-de", "")
+        self.tarfile.add_file("i18n/Translation-de", b"")
         self.process()
         self.assertTrue(os.path.exists(
             self.getTranslationsPath("Translation-de")))
@@ -65,7 +67,7 @@
     def test_ignores_empty_directories(self):
         # Empty directories in the tarball are not extracted.
         self.openArchive("20060728")
-        self.tarfile.add_file("i18n/Translation-de", "")
+        self.tarfile.add_file("i18n/Translation-de", b"")
         self.tarfile.add_directory("i18n/foo")
         self.process()
         self.assertTrue(os.path.exists(
@@ -76,15 +78,15 @@
         # If a DDTP tarball only contains a subset of published translation
         # files, these are updated and the rest are left untouched.
         self.openArchive("20060728")
-        self.tarfile.add_file("i18n/Translation-bn", "bn")
-        self.tarfile.add_file("i18n/Translation-ca", "ca")
+        self.tarfile.add_file("i18n/Translation-bn", b"bn")
+        self.tarfile.add_file("i18n/Translation-ca", b"ca")
         self.process()
         with open(self.getTranslationsPath("Translation-bn")) as bn_file:
             self.assertEqual("bn", bn_file.read())
         with open(self.getTranslationsPath("Translation-ca")) as ca_file:
             self.assertEqual("ca", ca_file.read())
         self.openArchive("20060817")
-        self.tarfile.add_file("i18n/Translation-bn", "new bn")
+        self.tarfile.add_file("i18n/Translation-bn", b"new bn")
         self.process()
         with open(self.getTranslationsPath("Translation-bn")) as bn_file:
             self.assertEqual("new bn", bn_file.read())
@@ -98,7 +100,7 @@
         # into place, so making this work requires special care.  Test that
         # that care has been taken.
         self.openArchive("20060728")
-        self.tarfile.add_file("i18n/Translation-ca", "")
+        self.tarfile.add_file("i18n/Translation-ca", b"")
         self.process()
         ca = self.getTranslationsPath("Translation-ca")
         bn = self.getTranslationsPath("Translation-bn")
@@ -107,7 +109,7 @@
         self.assertEqual(2, os.stat(bn).st_nlink)
         self.assertEqual(2, os.stat(ca).st_nlink)
         self.openArchive("20060817")
-        self.tarfile.add_file("i18n/Translation-bn", "break hard link")
+        self.tarfile.add_file("i18n/Translation-bn", b"break hard link")
         self.process()
         with open(bn) as bn_file:
             self.assertEqual("break hard link", bn_file.read())

=== modified file 'lib/lp/archivepublisher/tests/test_deathrow.py'
--- lib/lp/archivepublisher/tests/test_deathrow.py	2016-09-24 06:21:55 +0000
+++ lib/lp/archivepublisher/tests/test_deathrow.py	2018-02-02 11:57:41 +0000
@@ -1,8 +1,10 @@
-# Copyright 2009-2010 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2018 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Tests for deathrow class."""
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 __metaclass__ = type
 
 

=== modified file 'lib/lp/archivepublisher/tests/test_debian_installer.py'
--- lib/lp/archivepublisher/tests/test_debian_installer.py	2016-06-07 17:07:35 +0000
+++ lib/lp/archivepublisher/tests/test_debian_installer.py	2018-02-02 11:57:41 +0000
@@ -1,4 +1,4 @@
-# Copyright 2012-2016 Canonical Ltd.  This software is licensed under the
+# Copyright 2012-2018 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Test debian-installer custom uploads.
@@ -7,6 +7,8 @@
 high-level tests of debian-installer upload and queue manipulation.
 """
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 import os
 
 from zope.component import getUtility
@@ -77,7 +79,7 @@
     def test_basic(self):
         # Processing a simple correct tar file succeeds.
         self.openArchive()
-        self.addFile("hello", "world")
+        self.addFile("hello", b"world")
         self.process()
 
     def test_already_exists(self):
@@ -89,14 +91,14 @@
     def test_bad_umask(self):
         # The umask must be 0o022 to avoid incorrect permissions.
         self.openArchive()
-        self.addFile("dir/file", "foo")
+        self.addFile("dir/file", b"foo")
         os.umask(0o002)  # cleanup already handled by setUp
         self.assertRaises(CustomUploadBadUmask, self.process)
 
     def test_current_symlink(self):
         # A "current" symlink is created to the last version.
         self.openArchive()
-        self.addFile("hello", "world")
+        self.addFile("hello", b"world")
         self.process()
         installer_path = self.getInstallerPath()
         self.assertContentEqual(
@@ -112,8 +114,8 @@
         filename = os.path.join(directory, "default")
         long_filename = os.path.join(
             directory, "very_very_very_very_very_very_long_filename")
-        self.addFile(filename, "hey")
-        self.addFile(long_filename, "long")
+        self.addFile(filename, b"hey")
+        self.addFile(long_filename, b"long")
         self.process()
         with open(self.getInstallerPath(filename)) as f:
             self.assertEqual("hey", f.read())
@@ -140,7 +142,7 @@
     def test_top_level_permissions(self):
         # Top-level directories are set to mode 0o755 (see bug 107068).
         self.openArchive()
-        self.addFile("hello", "world")
+        self.addFile("hello", b"world")
         self.process()
         installer_path = self.getInstallerPath()
         self.assertEqual(0o755, os.stat(installer_path).st_mode & 0o777)
@@ -154,7 +156,7 @@
         directory = ("images/netboot/ubuntu-installer/i386/"
                      "pxelinux.cfg.serial-9600")
         filename = os.path.join(directory, "default")
-        self.addFile(filename, "hey")
+        self.addFile(filename, b"hey")
         self.process()
         self.assertEqual(
             0o644, os.stat(self.getInstallerPath(filename)).st_mode & 0o777)

=== modified file 'lib/lp/archivepublisher/tests/test_debversion.py'
--- lib/lp/archivepublisher/tests/test_debversion.py	2018-01-02 16:10:26 +0000
+++ lib/lp/archivepublisher/tests/test_debversion.py	2018-02-02 11:57:41 +0000
@@ -1,8 +1,10 @@
-# Copyright 2009-2010 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2018 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Tests for debversion."""
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 __metaclass__ = type
 
 # These tests came from sourcerer.

=== modified file 'lib/lp/archivepublisher/tests/test_dist_upgrader.py'
--- lib/lp/archivepublisher/tests/test_dist_upgrader.py	2016-06-07 17:07:35 +0000
+++ lib/lp/archivepublisher/tests/test_dist_upgrader.py	2018-02-02 11:57:41 +0000
@@ -1,4 +1,4 @@
-# Copyright 2012-2016 Canonical Ltd.  This software is licensed under the
+# Copyright 2012-2018 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Test dist-upgrader custom uploads.
@@ -7,6 +7,8 @@
 tests of dist-upgrader upload and queue manipulation.
 """
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 import os
 
 from zope.component import getUtility
@@ -71,27 +73,27 @@
     def test_basic(self):
         # Processing a simple correct tar file works.
         self.openArchive("20060302.0120")
-        self.tarfile.add_file("20060302.0120/hello", "world")
+        self.tarfile.add_file("20060302.0120/hello", b"world")
         self.process()
 
     def test_already_exists(self):
         # If the target directory already exists, processing fails.
         self.openArchive("20060302.0120")
-        self.tarfile.add_file("20060302.0120/hello", "world")
+        self.tarfile.add_file("20060302.0120/hello", b"world")
         os.makedirs(os.path.join(self.getUpgraderPath(), "20060302.0120"))
         self.assertRaises(CustomUploadAlreadyExists, self.process)
 
     def test_bad_umask(self):
         # The umask must be 0o022 to avoid incorrect permissions.
         self.openArchive("20060302.0120")
-        self.tarfile.add_file("20060302.0120/file", "foo")
+        self.tarfile.add_file("20060302.0120/file", b"foo")
         os.umask(0o002)  # cleanup already handled by setUp
         self.assertRaises(CustomUploadBadUmask, self.process)
 
     def test_current_symlink(self):
         # A "current" symlink is created to the last version.
         self.openArchive("20060302.0120")
-        self.tarfile.add_file("20060302.0120/hello", "world")
+        self.tarfile.add_file("20060302.0120/hello", b"world")
         self.process()
         upgrader_path = self.getUpgraderPath()
         self.assertContentEqual(
@@ -106,7 +108,7 @@
     def test_bad_version(self):
         # Bad versions in the tarball are refused.
         self.openArchive("20070219.1234")
-        self.tarfile.add_file("foobar/foobar/dapper.tar.gz", "")
+        self.tarfile.add_file("foobar/foobar/dapper.tar.gz", b"")
         self.assertRaises(DistUpgraderBadVersion, self.process)
 
     def test_getSeriesKey_extracts_architecture(self):

=== modified file 'lib/lp/archivepublisher/tests/test_dominator.py'
--- lib/lp/archivepublisher/tests/test_dominator.py	2014-10-31 10:34:51 +0000
+++ lib/lp/archivepublisher/tests/test_dominator.py	2018-02-02 11:57:41 +0000
@@ -1,8 +1,10 @@
-# Copyright 2009-2011 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2018 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Tests for domination.py."""
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 __metaclass__ = type
 
 import datetime

=== modified file 'lib/lp/archivepublisher/tests/test_ftparchive.py'
--- lib/lp/archivepublisher/tests/test_ftparchive.py	2017-01-13 12:28:34 +0000
+++ lib/lp/archivepublisher/tests/test_ftparchive.py	2018-02-02 11:57:41 +0000
@@ -1,8 +1,10 @@
-# Copyright 2009-2017 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2018 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Tests for ftparchive.py"""
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 __metaclass__ = type
 
 import difflib
@@ -254,7 +256,7 @@
         extra_overrides = os.path.join(
             self._confdir, "more-extra.override.hoary-test.main")
         with open(extra_overrides, "w") as extra_override_file:
-            print >>extra_override_file, "  ".join(sentinel)
+            print("  ".join(sentinel), file=extra_override_file)
         self._publishDefaultOverrides(fa, 'universe')
 
         result_path = os.path.join(
@@ -332,7 +334,7 @@
         self._publisher = SamplePublisher(self._archive)
         fa = self._setUpFTPArchiveHandler()
         pubs = self._archive.getAllPublishedBinaries(
-            name=u"pmount", status=PackagePublishingStatus.PUBLISHED,
+            name="pmount", status=PackagePublishingStatus.PUBLISHED,
             distroarchseries=self._distribution.getSeries("hoary")["hppa"])
         for pub in pubs:
             pub.changeOverride(new_phased_update_percentage=30).setPublished()
@@ -377,10 +379,10 @@
 
     def makeDDEBPub(self, series):
         self.factory.makeBinaryPackagePublishingHistory(
-            binarypackagename=u'foo', sourcepackagename='foo', version='666',
+            binarypackagename='foo', sourcepackagename='foo', version='666',
             archive=series.main_archive, distroarchseries=series['hppa'],
             pocket=PackagePublishingPocket.RELEASE,
-            component=u'main', with_debug=True, with_file=True,
+            component='main', with_debug=True, with_file=True,
             status=PackagePublishingStatus.PUBLISHED,
             architecturespecific=True)
 

=== modified file 'lib/lp/archivepublisher/tests/test_generate_contents_files.py'
--- lib/lp/archivepublisher/tests/test_generate_contents_files.py	2016-11-01 10:28:15 +0000
+++ lib/lp/archivepublisher/tests/test_generate_contents_files.py	2018-02-02 11:57:41 +0000
@@ -1,8 +1,10 @@
-# Copyright 2011-2016 Canonical Ltd.  This software is licensed under the
+# Copyright 2011-2018 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Test for the `generate-contents-files` script."""
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 __metaclass__ = type
 
 import hashlib

=== modified file 'lib/lp/archivepublisher/tests/test_generate_ppa_htaccess.py'
--- lib/lp/archivepublisher/tests/test_generate_ppa_htaccess.py	2016-07-14 14:12:23 +0000
+++ lib/lp/archivepublisher/tests/test_generate_ppa_htaccess.py	2018-02-02 11:57:41 +0000
@@ -1,8 +1,10 @@
-# Copyright 2009-2015 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2018 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Test the generate_ppa_htaccess.py script. """
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 import crypt
 from datetime import (
     datetime,
@@ -75,7 +77,7 @@
         self.ppa.distribution = ubuntutest
 
         # Enable named auth tokens.
-        self.useFixture(FeatureFixture({NAMED_AUTH_TOKEN_FEATURE_FLAG: u"on"}))
+        self.useFixture(FeatureFixture({NAMED_AUTH_TOKEN_FEATURE_FLAG: "on"}))
 
     def getScript(self, test_args=None):
         """Return a HtaccessTokenGenerator instance."""
@@ -266,8 +268,8 @@
         team1_person = persons1[0]
 
         # Named tokens should be ignored for deactivation.
-        self.ppa.newNamedAuthToken(u"tokenname1")
-        named_token = self.ppa.newNamedAuthToken(u"tokenname2")
+        self.ppa.newNamedAuthToken("tokenname1")
+        named_token = self.ppa.newNamedAuthToken("tokenname2")
         named_token.deactivate()
 
         # Initially, nothing is eligible for deactivation.
@@ -335,7 +337,7 @@
         sub2 = self.ppa.newSubscription(name16, self.ppa.owner)
         token1 = self.ppa.newAuthToken(name12)
         token2 = self.ppa.newAuthToken(name16)
-        token3 = self.ppa.newNamedAuthToken(u"tokenname3")
+        token3 = self.ppa.newNamedAuthToken("tokenname3")
         self.layer.txn.commit()
         return (sub1, sub2), (token1, token2, token3)
 
@@ -384,9 +386,9 @@
 
     def testBasicOperation_with_named_tokens(self):
         """Invoke the actual script and make sure it generates some files."""
-        token1 = self.ppa.newNamedAuthToken(u"tokenname1")
-        token2 = self.ppa.newNamedAuthToken(u"tokenname2")
-        token3 = self.ppa.newNamedAuthToken(u"tokenname3")
+        token1 = self.ppa.newNamedAuthToken("tokenname1")
+        token2 = self.ppa.newNamedAuthToken("tokenname2")
+        token3 = self.ppa.newNamedAuthToken("tokenname3")
         token3.deactivate()
 
         # Call the script and check that we have a .htaccess and a .htpasswd.
@@ -641,10 +643,10 @@
         last_start = datetime.now(pytz.UTC) - timedelta(seconds=90)
         before_last_start = last_start - timedelta(seconds=30)
 
-        self.ppa.newNamedAuthToken(u"tokenname1")
-        token2 = self.ppa.newNamedAuthToken(u"tokenname2")
+        self.ppa.newNamedAuthToken("tokenname1")
+        token2 = self.ppa.newNamedAuthToken("tokenname2")
         token2.deactivate()
-        token3 = self.ppa.newNamedAuthToken(u"tokenname3")
+        token3 = self.ppa.newNamedAuthToken("tokenname3")
         token3.date_deactivated = before_last_start
 
         script = self.getScript()
@@ -657,12 +659,12 @@
         before_last_start = last_start - timedelta(seconds=30)
         tomorrow = datetime.now(pytz.UTC) + timedelta(days=1)
 
-        self.ppa.newNamedAuthToken(u"tokenname1")
-        token2 = self.ppa.newNamedAuthToken(u"tokenname2")
+        self.ppa.newNamedAuthToken("tokenname1")
+        token2 = self.ppa.newNamedAuthToken("tokenname2")
         token2.deactivate()
-        token3 = self.ppa.newNamedAuthToken(u"tokenname3")
+        token3 = self.ppa.newNamedAuthToken("tokenname3")
         token3.date_deactivated = before_last_start
-        token4 = self.ppa.newNamedAuthToken(u"tokenname4")
+        token4 = self.ppa.newNamedAuthToken("tokenname4")
         token4.date_deactivated = tomorrow
 
         script = self.getScript()

=== modified file 'lib/lp/archivepublisher/tests/test_htaccess.py'
--- lib/lp/archivepublisher/tests/test_htaccess.py	2018-01-02 16:10:26 +0000
+++ lib/lp/archivepublisher/tests/test_htaccess.py	2018-02-02 11:57:41 +0000
@@ -1,8 +1,10 @@
-# Copyright 2009-2017 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2018 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Test htaccess/htpasswd file generation. """
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 import os
 import tempfile
 
@@ -39,7 +41,7 @@
         self.ppa.distribution = ubuntutest
 
         # Enable named auth tokens.
-        self.useFixture(FeatureFixture({NAMED_AUTH_TOKEN_FEATURE_FLAG: u"on"}))
+        self.useFixture(FeatureFixture({NAMED_AUTH_TOKEN_FEATURE_FLAG: "on"}))
 
     def test_write_htpasswd(self):
         """Test that writing the .htpasswd file works properly."""
@@ -118,9 +120,9 @@
         first_created_token = self.ppa.newAuthToken(name16)
         second_created_token = self.ppa.newAuthToken(name12)
         third_created_token = self.ppa.newAuthToken(hyphenated)
-        named_token_20 = self.ppa.newNamedAuthToken(u"name20", as_dict=False)
-        named_token_14 = self.ppa.newNamedAuthToken(u"name14", as_dict=False)
-        named_token_99 = self.ppa.newNamedAuthToken(u"name99", as_dict=False)
+        named_token_20 = self.ppa.newNamedAuthToken("name20", as_dict=False)
+        named_token_14 = self.ppa.newNamedAuthToken("name14", as_dict=False)
+        named_token_99 = self.ppa.newNamedAuthToken("name99", as_dict=False)
         named_token_99.deactivate()
 
         expected_credentials = [

=== modified file 'lib/lp/archivepublisher/tests/test_indices.py'
--- lib/lp/archivepublisher/tests/test_indices.py	2016-02-05 15:16:29 +0000
+++ lib/lp/archivepublisher/tests/test_indices.py	2018-02-02 11:57:41 +0000
@@ -1,8 +1,10 @@
-# Copyright 2009-2013 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2018 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Test native archive index generation for Soyuz."""
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 import os
 import tempfile
 import unittest
@@ -70,27 +72,27 @@
                 ("Build-Conflicts-Arch", "libbar-dev")])
 
         self.assertEqual(
-            [u'Package: foo',
-             u'Binary: foo-bin',
-             u'Version: 666',
-             u'Section: base',
-             u'Maintainer: Foo Bar <foo@xxxxxxx>',
-             u'Build-Depends: fooish',
-             u'Build-Depends-Indep: pyfoo',
-             u'Build-Depends-Arch: libfoo-dev',
-             u'Build-Conflicts: bar',
-             u'Build-Conflicts-Indep: pybar',
-             u'Build-Conflicts-Arch: libbar-dev',
-             u'Architecture: all',
-             u'Standards-Version: 3.6.2',
-             u'Format: 1.0',
-             u'Directory: pool/main/f/foo',
-             u'Files:',
-             u' %s 28 foo_666.dsc' % self.dsc_md5,
-             u'Checksums-Sha1:',
-             u' %s 28 foo_666.dsc' % self.dsc_sha1,
-             u'Checksums-Sha256:',
-             u' %s 28 foo_666.dsc' % self.dsc_sha256,
+            ['Package: foo',
+             'Binary: foo-bin',
+             'Version: 666',
+             'Section: base',
+             'Maintainer: Foo Bar <foo@xxxxxxx>',
+             'Build-Depends: fooish',
+             'Build-Depends-Indep: pyfoo',
+             'Build-Depends-Arch: libfoo-dev',
+             'Build-Conflicts: bar',
+             'Build-Conflicts-Indep: pybar',
+             'Build-Conflicts-Arch: libbar-dev',
+             'Architecture: all',
+             'Standards-Version: 3.6.2',
+             'Format: 1.0',
+             'Directory: pool/main/f/foo',
+             'Files:',
+             ' %s 28 foo_666.dsc' % self.dsc_md5,
+             'Checksums-Sha1:',
+             ' %s 28 foo_666.dsc' % self.dsc_sha1,
+             'Checksums-Sha256:',
+             ' %s 28 foo_666.dsc' % self.dsc_sha256,
              ],
             build_spph_stanza(pub_source).makeOutput().splitlines())
 
@@ -112,28 +114,28 @@
                 ("Build-Conflicts-Arch", "libbar-dev")])
 
         self.assertEqual(
-            [u'Package: foo',
-             u'Binary: foo-bin',
-             u'Version: 666',
-             u'Section: base',
-             u'Maintainer: Foo Bar <foo@xxxxxxx>',
-             u'Build-Depends: fooish',
-             u'Build-Depends-Indep: pyfoo',
-             u'Build-Depends-Arch: libfoo-dev',
-             u'Build-Conflicts: bar',
-             u'Build-Conflicts-Indep: pybar',
-             u'Build-Conflicts-Arch: libbar-dev',
-             u'Architecture: all',
-             u'Standards-Version: 3.6.2',
-             u'Format: 1.0',
-             u'Directory: pool/main/f/foo',
-             u'Files:',
-             u' %s 28 foo_666.dsc' % self.dsc_md5,
-             u'Checksums-Sha1:',
-             u' %s 28 foo_666.dsc' % self.dsc_sha1,
-             u'Checksums-Sha256:',
-             u' %s 28 foo_666.dsc' % self.dsc_sha256,
-             u'Python-Version: < 1.5'],
+            ['Package: foo',
+             'Binary: foo-bin',
+             'Version: 666',
+             'Section: base',
+             'Maintainer: Foo Bar <foo@xxxxxxx>',
+             'Build-Depends: fooish',
+             'Build-Depends-Indep: pyfoo',
+             'Build-Depends-Arch: libfoo-dev',
+             'Build-Conflicts: bar',
+             'Build-Conflicts-Indep: pybar',
+             'Build-Conflicts-Arch: libbar-dev',
+             'Architecture: all',
+             'Standards-Version: 3.6.2',
+             'Format: 1.0',
+             'Directory: pool/main/f/foo',
+             'Files:',
+             ' %s 28 foo_666.dsc' % self.dsc_md5,
+             'Checksums-Sha1:',
+             ' %s 28 foo_666.dsc' % self.dsc_sha1,
+             'Checksums-Sha256:',
+             ' %s 28 foo_666.dsc' % self.dsc_sha256,
+             'Python-Version: < 1.5'],
             build_spph_stanza(pub_source).makeOutput().splitlines())
 
     def testBinaryStanza(self):
@@ -149,32 +151,32 @@
             phased_update_percentage=50)
         pub_binary = pub_binaries[0]
         self.assertEqual(
-            [u'Package: foo-bin',
-             u'Source: foo',
-             u'Priority: standard',
-             u'Section: base',
-             u'Installed-Size: 100',
-             u'Maintainer: Foo Bar <foo@xxxxxxx>',
-             u'Architecture: all',
-             u'Version: 666',
-             u'Recommends: foo-dev',
-             u'Replaces: old-foo',
-             u'Suggests: pyfoo',
-             u'Provides: foo-master',
-             u'Depends: biscuit',
-             u'Conflicts: old-foo',
-             u'Pre-Depends: master-foo',
-             u'Enhances: foo-super',
-             u'Breaks: old-foo',
-             u'Filename: pool/main/f/foo/foo-bin_666_all.deb',
-             u'Size: 18',
-             u'MD5sum: ' + self.deb_md5,
-             u'SHA1: ' + self.deb_sha1,
-             u'SHA256: ' + self.deb_sha256,
-             u'Phased-Update-Percentage: 50',
-             u'Description: Foo app is great',
-             u' Well ...',
-             u' it does nothing, though'],
+            ['Package: foo-bin',
+             'Source: foo',
+             'Priority: standard',
+             'Section: base',
+             'Installed-Size: 100',
+             'Maintainer: Foo Bar <foo@xxxxxxx>',
+             'Architecture: all',
+             'Version: 666',
+             'Recommends: foo-dev',
+             'Replaces: old-foo',
+             'Suggests: pyfoo',
+             'Provides: foo-master',
+             'Depends: biscuit',
+             'Conflicts: old-foo',
+             'Pre-Depends: master-foo',
+             'Enhances: foo-super',
+             'Breaks: old-foo',
+             'Filename: pool/main/f/foo/foo-bin_666_all.deb',
+             'Size: 18',
+             'MD5sum: ' + self.deb_md5,
+             'SHA1: ' + self.deb_sha1,
+             'SHA256: ' + self.deb_sha256,
+             'Phased-Update-Percentage: 50',
+             'Description: Foo app is great',
+             ' Well ...',
+             ' it does nothing, though'],
             build_bpph_stanza(pub_binary).makeOutput().splitlines())
 
     def testBinaryStanzaWithCustomFields(self):
@@ -189,32 +191,32 @@
             user_defined_fields=[("Python-Version", ">= 2.4")])
         pub_binary = pub_binaries[0]
         self.assertEqual(
-            [u'Package: foo-bin',
-             u'Source: foo',
-             u'Priority: standard',
-             u'Section: base',
-             u'Installed-Size: 100',
-             u'Maintainer: Foo Bar <foo@xxxxxxx>',
-             u'Architecture: all',
-             u'Version: 666',
-             u'Recommends: foo-dev',
-             u'Replaces: old-foo',
-             u'Suggests: pyfoo',
-             u'Provides: foo-master',
-             u'Depends: biscuit',
-             u'Conflicts: old-foo',
-             u'Pre-Depends: master-foo',
-             u'Enhances: foo-super',
-             u'Breaks: old-foo',
-             u'Filename: pool/main/f/foo/foo-bin_666_all.deb',
-             u'Size: 18',
-             u'MD5sum: ' + self.deb_md5,
-             u'SHA1: ' + self.deb_sha1,
-             u'SHA256: ' + self.deb_sha256,
-             u'Description: Foo app is great',
-             u' Well ...',
-             u' it does nothing, though',
-             u'Python-Version: >= 2.4'],
+            ['Package: foo-bin',
+             'Source: foo',
+             'Priority: standard',
+             'Section: base',
+             'Installed-Size: 100',
+             'Maintainer: Foo Bar <foo@xxxxxxx>',
+             'Architecture: all',
+             'Version: 666',
+             'Recommends: foo-dev',
+             'Replaces: old-foo',
+             'Suggests: pyfoo',
+             'Provides: foo-master',
+             'Depends: biscuit',
+             'Conflicts: old-foo',
+             'Pre-Depends: master-foo',
+             'Enhances: foo-super',
+             'Breaks: old-foo',
+             'Filename: pool/main/f/foo/foo-bin_666_all.deb',
+             'Size: 18',
+             'MD5sum: ' + self.deb_md5,
+             'SHA1: ' + self.deb_sha1,
+             'SHA256: ' + self.deb_sha256,
+             'Description: Foo app is great',
+             ' Well ...',
+             ' it does nothing, though',
+             'Python-Version: >= 2.4'],
             build_bpph_stanza(pub_binary).makeOutput().splitlines())
 
     def testBinaryStanzaDescription(self):
@@ -245,26 +247,26 @@
             description=description)[0]
 
         self.assertEqual(
-            [u'Package: foo-bin',
-             u'Source: foo',
-             u'Priority: standard',
-             u'Section: base',
-             u'Installed-Size: 100',
-             u'Maintainer: Foo Bar <foo@xxxxxxx>',
-             u'Architecture: all',
-             u'Version: 666',
-             u'Filename: pool/main/f/foo/foo-bin_666_all.deb',
-             u'Size: 18',
-             u'MD5sum: ' + self.deb_md5,
-             u'SHA1: ' + self.deb_sha1,
-             u'SHA256: ' + self.deb_sha256,
-             u'Description: Foo app is great',
-             u' Normal',
-             u' Normal',
-             u' .',
-             u' .',
-             u' .',
-             u' %s' % ('x' * 100),
+            ['Package: foo-bin',
+             'Source: foo',
+             'Priority: standard',
+             'Section: base',
+             'Installed-Size: 100',
+             'Maintainer: Foo Bar <foo@xxxxxxx>',
+             'Architecture: all',
+             'Version: 666',
+             'Filename: pool/main/f/foo/foo-bin_666_all.deb',
+             'Size: 18',
+             'MD5sum: ' + self.deb_md5,
+             'SHA1: ' + self.deb_sha1,
+             'SHA256: ' + self.deb_sha256,
+             'Description: Foo app is great',
+             ' Normal',
+             ' Normal',
+             ' .',
+             ' .',
+             ' .',
+             ' %s' % ('x' * 100),
              ],
             build_bpph_stanza(pub_binary).makeOutput().splitlines())
 
@@ -277,26 +279,26 @@
         The encoding should be preserved and able to be encoded in
         'utf-8' for disk writing.
         """
-        description = u'Using non-ascii as: \xe7\xe3\xe9\xf3'
+        description = 'Using non-ascii as: \xe7\xe3\xe9\xf3'
         pub_binary = self.getPubBinaries(
             description=description)[0]
 
         self.assertEqual(
-            [u'Package: foo-bin',
-             u'Source: foo',
-             u'Priority: standard',
-             u'Section: base',
-             u'Installed-Size: 100',
-             u'Maintainer: Foo Bar <foo@xxxxxxx>',
-             u'Architecture: all',
-             u'Version: 666',
-             u'Filename: pool/main/f/foo/foo-bin_666_all.deb',
-             u'Size: 18',
-             u'MD5sum: ' + self.deb_md5,
-             u'SHA1: ' + self.deb_sha1,
-             u'SHA256: ' + self.deb_sha256,
-             u'Description: Foo app is great',
-             u' Using non-ascii as: \xe7\xe3\xe9\xf3',
+            ['Package: foo-bin',
+             'Source: foo',
+             'Priority: standard',
+             'Section: base',
+             'Installed-Size: 100',
+             'Maintainer: Foo Bar <foo@xxxxxxx>',
+             'Architecture: all',
+             'Version: 666',
+             'Filename: pool/main/f/foo/foo-bin_666_all.deb',
+             'Size: 18',
+             'MD5sum: ' + self.deb_md5,
+             'SHA1: ' + self.deb_sha1,
+             'SHA256: ' + self.deb_sha256,
+             'Description: Foo app is great',
+             ' Using non-ascii as: \xe7\xe3\xe9\xf3',
              ],
             build_bpph_stanza(pub_binary).makeOutput().splitlines())
 
@@ -315,7 +317,7 @@
         pub_binary = self.getPubBinaries(
             binaryname='foo-bin', pub_source=pub_source)[0]
         self.assertEqual(
-            u'foo',
+            'foo',
             get_field(build_bpph_stanza(pub_binary), 'Source'))
 
     def testBinaryIncludesDifferingSourceVersion(self):
@@ -324,7 +326,7 @@
         pub_binary = self.getPubBinaries(
             binaryname='foo', version='999', pub_source=pub_source)[0]
         self.assertEqual(
-            u'foo (666)',
+            'foo (666)',
             get_field(build_bpph_stanza(pub_binary), 'Source'))
 
 

=== modified file 'lib/lp/archivepublisher/tests/test_pool.py'
--- lib/lp/archivepublisher/tests/test_pool.py	2010-12-20 07:52:32 +0000
+++ lib/lp/archivepublisher/tests/test_pool.py	2018-02-02 11:57:41 +0000
@@ -1,8 +1,10 @@
-# Copyright 2009-2010 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2018 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Tests for pool.py."""
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 __metaclass__ = type
 
 import hashlib

=== modified file 'lib/lp/archivepublisher/tests/test_processaccepted.py'
--- lib/lp/archivepublisher/tests/test_processaccepted.py	2014-08-09 19:45:00 +0000
+++ lib/lp/archivepublisher/tests/test_processaccepted.py	2018-02-02 11:57:41 +0000
@@ -1,8 +1,10 @@
-# Copyright 2010-2014 Canonical Ltd.  This software is licensed under the
+# Copyright 2010-2018 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Test process-accepted.py"""
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 from optparse import OptionValueError
 
 from testtools.matchers import LessThan
@@ -35,7 +37,7 @@
         TestCaseWithFactory.setUp(self)
         self.stp = SoyuzTestPublisher()
         self.stp.prepareBreezyAutotest()
-        self.test_package_name = u"accept-test"
+        self.test_package_name = "accept-test"
         self.distro = self.factory.makeDistribution()
 
     def getScript(self, test_args=None):

=== modified file 'lib/lp/archivepublisher/tests/test_processdeathrow.py'
--- lib/lp/archivepublisher/tests/test_processdeathrow.py	2014-08-09 19:45:00 +0000
+++ lib/lp/archivepublisher/tests/test_processdeathrow.py	2018-02-02 11:57:41 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009-2010 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2018 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Functional tests for process-death-row.py script.
@@ -8,6 +8,8 @@
 processes its arguments and handles dry-run correctly.
 """
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 __metaclass__ = type
 
 import datetime
@@ -105,12 +107,12 @@
 
         cprov = getUtility(IPersonSet).getByName('cprov')
         removeSecurityProxy(cprov.archive).distribution = ubuntutest
-        ppa_pubrecs = cprov.archive.getPublishedSources(u'iceweasel')
+        ppa_pubrecs = cprov.archive.getPublishedSources('iceweasel')
         self.ppa_pubrec_ids = self.markPublishingForRemoval(ppa_pubrecs)
 
         mark = getUtility(IPersonSet).getByName('mark')
         removeSecurityProxy(mark.archive).distribution = ubuntutest
-        ppa_pubrecs = mark.archive.getPublishedSources(u'iceweasel')
+        ppa_pubrecs = mark.archive.getPublishedSources('iceweasel')
         self.ppa_pubrec_ids.extend(self.markPublishingForRemoval(ppa_pubrecs))
 
         # Fill one of the files in cprov PPA just to ensure that deathrow

=== modified file 'lib/lp/archivepublisher/tests/test_publish_ftpmaster.py'
--- lib/lp/archivepublisher/tests/test_publish_ftpmaster.py	2016-12-05 22:16:25 +0000
+++ lib/lp/archivepublisher/tests/test_publish_ftpmaster.py	2018-02-02 11:57:41 +0000
@@ -1,8 +1,10 @@
-# Copyright 2011-2016 Canonical Ltd.  This software is licensed under the
+# Copyright 2011-2018 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Test publish-ftpmaster cron script."""
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 __metaclass__ = type
 
 import logging
@@ -1306,7 +1308,7 @@
         have_fresh_series = script.prepareFreshSeries(distro)
         self.assertTrue(have_fresh_series)
         [copied_upload] = new_series.getPackageUploads(
-            name=u'debian-installer-images', exact_match=False)
+            name='debian-installer-images', exact_match=False)
         [copied_custom] = copied_upload.customfiles
         self.assertEqual(
             custom_upload.customfiles[0].libraryfilealias.filename,

=== modified file 'lib/lp/archivepublisher/tests/test_publishdistro.py'
--- lib/lp/archivepublisher/tests/test_publishdistro.py	2017-04-29 15:24:32 +0000
+++ lib/lp/archivepublisher/tests/test_publishdistro.py	2018-02-02 11:57:41 +0000
@@ -1,8 +1,10 @@
-# Copyright 2009-2017 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2018 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Functional tests for publish-distro.py script."""
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 __metaclass__ = type
 
 from optparse import OptionValueError

=== modified file 'lib/lp/archivepublisher/tests/test_publisher.py'
--- lib/lp/archivepublisher/tests/test_publisher.py	2017-04-29 15:24:32 +0000
+++ lib/lp/archivepublisher/tests/test_publisher.py	2018-02-02 11:57:41 +0000
@@ -1,8 +1,10 @@
-# Copyright 2009-2017 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2018 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Tests for publisher class."""
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 __metaclass__ = type
 
 import bz2
@@ -450,7 +452,7 @@
         for pu_build in pu_i386.builds:
             pu_build.publish()
 
-        publications = archive.getAllPublishedBinaries(name=u"bin-i386")
+        publications = archive.getAllPublishedBinaries(name="bin-i386")
 
         self.assertEqual(1, publications.count())
         self.assertEqual(
@@ -809,14 +811,14 @@
         self.assertFalse(os.path.exists(publisher._config.metaroot))
         self.assertEqual(ArchiveStatus.DELETED, test_archive.status)
         self.assertEqual(False, test_archive.publish)
-        self.assertEqual(u'testing-deletedppa', test_archive.name)
+        self.assertEqual('testing-deletedppa', test_archive.name)
 
         # All of the archive's active publications have been marked
         # DELETED, and dateremoved has been set early because they've
         # already been removed from disk.
         for pub in (spph, bpph, orphaned_bpph):
             self.assertEqual(PackagePublishingStatus.DELETED, pub.status)
-            self.assertEqual(u'janitor', pub.removed_by.name)
+            self.assertEqual('janitor', pub.removed_by.name)
             self.assertIsNot(None, pub.dateremoved)
 
         # The SUPERSEDED publications now have dateremoved set, even
@@ -1252,7 +1254,7 @@
         self.assertEqual(
             cprov.archive, archive_publisher.archive)
         self.assertEqual(
-            u'/var/tmp/ppa.test/cprov/ppa/ubuntutest/dists',
+            '/var/tmp/ppa.test/cprov/ppa/ubuntutest/dists',
             archive_publisher._config.distsroot)
         self.assertEqual(
             [('breezy-autotest', PackagePublishingPocket.RELEASE)],
@@ -1933,7 +1935,7 @@
         """
         allowed_suites = []
         cprov = getUtility(IPersonSet).getByName('cprov')
-        cprov.archive.displayname = u'PPA for Celso Provid\xe8lo'
+        cprov.archive.displayname = 'PPA for Celso Provid\xe8lo'
         archive_publisher = getPublisher(
             cprov.archive, allowed_suites, self.logger)
 
@@ -1950,7 +1952,7 @@
         self.assertEqual('LP-PPA-cprov', release['origin'])
 
         # The Label: field should be set to the archive displayname
-        self.assertEqual(u'PPA for Celso Provid\xe8lo', release['label'])
+        self.assertEqual('PPA for Celso Provid\xe8lo', release['label'])
 
         arch_sources_path = os.path.join(
             archive_publisher._config.distsroot, 'breezy-autotest',
@@ -2720,7 +2722,7 @@
         # A no-op run leaves the scheduled deletion date intact.
         i386_file = getUtility(IArchiveFileSet).getByArchive(
             self.ubuntutest.main_archive,
-            path=u'dists/breezy-autotest/Contents-i386').one()
+            path='dists/breezy-autotest/Contents-i386').one()
         i386_date = i386_file.scheduled_deletion_date
         self.runSteps(publisher, step_d=True)
         flush_database_caches()
@@ -2746,7 +2748,7 @@
         # Arrange for the second file to be pruned.
         hppa_file = getUtility(IArchiveFileSet).getByArchive(
             self.ubuntutest.main_archive,
-            path=u'dists/breezy-autotest/Contents-hppa').one()
+            path='dists/breezy-autotest/Contents-hppa').one()
         removeSecurityProxy(hppa_file).scheduled_deletion_date = (
             now - timedelta(hours=1))
         self.runSteps(publisher, step_d=True)
@@ -2809,7 +2811,7 @@
             ByHashHasContents(main_contents))
         archive_files = getUtility(IArchiveFileSet).getByArchive(
             self.ubuntutest.main_archive,
-            path=u'dists/breezy-autotest/main/source/Sources')
+            path='dists/breezy-autotest/main/source/Sources')
         self.assertThat(
             sorted(archive_files, key=attrgetter('id')),
             MatchesListwise([

=== modified file 'lib/lp/archivepublisher/tests/test_publisher_documentation.py'
--- lib/lp/archivepublisher/tests/test_publisher_documentation.py	2012-01-20 15:42:44 +0000
+++ lib/lp/archivepublisher/tests/test_publisher_documentation.py	2018-02-02 11:57:41 +0000
@@ -1,8 +1,10 @@
-# Copyright 2009 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2018 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Runs the archivepublisher doctests."""
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 __metaclass__ = type
 
 import logging

=== modified file 'lib/lp/archivepublisher/tests/test_publisherconfig.py'
--- lib/lp/archivepublisher/tests/test_publisherconfig.py	2013-06-20 05:50:00 +0000
+++ lib/lp/archivepublisher/tests/test_publisherconfig.py	2018-02-02 11:57:41 +0000
@@ -1,8 +1,10 @@
-# Copyright 2011 Canonical Ltd.  This software is licensed under the
+# Copyright 2011-2018 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Tests for publisherConfig model class."""
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 __metaclass__ = type
 
 
@@ -45,9 +47,9 @@
 
     def test_properties(self):
         # Test the model properties.
-        ROOT_DIR = u"rootdir/test"
-        BASE_URL = u"http://base.url";
-        COPY_BASE_URL = u"http://base.url";
+        ROOT_DIR = "rootdir/test"
+        BASE_URL = "http://base.url";
+        COPY_BASE_URL = "http://base.url";
         pubconf = self.factory.makePublisherConfig(
             distribution=self.distribution,
             root_dir=ROOT_DIR,
@@ -83,7 +85,7 @@
 
     def test_only_admin(self):
         # Only admins can see and change the config.
-        distro = self.factory.makeDistribution(publish_root_dir=u"foo")
+        distro = self.factory.makeDistribution(publish_root_dir="foo")
         config = getUtility(IPublisherConfigSet).getByDistribution(distro)
 
         login(ANONYMOUS)
@@ -91,6 +93,6 @@
         self.assertRaises(Unauthorized, setattr, config, "root_dir", "test")
 
         login(LAUNCHPAD_ADMIN)
-        self.assertEqual(u"foo", config.root_dir)
-        config.root_dir = u"bar"
-        self.assertEqual(u"bar", config.root_dir)
+        self.assertEqual("foo", config.root_dir)
+        config.root_dir = "bar"
+        self.assertEqual("bar", config.root_dir)

=== modified file 'lib/lp/archivepublisher/tests/test_repositoryindexfile.py'
--- lib/lp/archivepublisher/tests/test_repositoryindexfile.py	2016-10-04 01:27:20 +0000
+++ lib/lp/archivepublisher/tests/test_repositoryindexfile.py	2018-02-02 11:57:41 +0000
@@ -1,8 +1,10 @@
-# Copyright 2009-2016 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2018 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Tests for `RepositoryIndexFile`."""
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 __metaclass__ = type
 
 import bz2

=== modified file 'lib/lp/archivepublisher/tests/test_rosetta_translations.py'
--- lib/lp/archivepublisher/tests/test_rosetta_translations.py	2016-05-23 10:14:39 +0000
+++ lib/lp/archivepublisher/tests/test_rosetta_translations.py	2018-02-02 11:57:41 +0000
@@ -1,4 +1,4 @@
-# Copyright 2013-2016 Canonical Ltd.  This software is licensed under the
+# Copyright 2013-2018 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Test rosetta-translations custom uploads.
@@ -7,6 +7,8 @@
 high-level tests of rosetta-translations upload and queue manipulation.
 """
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 from storm.expr import Desc
 import transaction
 from zope.component import getUtility
@@ -50,8 +52,8 @@
         """Create an LibraryFileAlias containing dummy translation data."""
         if tar_content is None:
             tar_content = {
-                'source/po/foo.pot': 'Foo template',
-                'source/po/eo.po': 'Foo translation',
+                'source/po/foo.pot': b'Foo template',
+                'source/po/eo.po': b'Foo translation',
                 }
         tarfile_content = LaunchpadWriteTarFile.files_to_string(
             tar_content)

=== modified file 'lib/lp/archivepublisher/tests/test_signing.py'
--- lib/lp/archivepublisher/tests/test_signing.py	2017-08-02 19:13:48 +0000
+++ lib/lp/archivepublisher/tests/test_signing.py	2018-02-02 11:57:41 +0000
@@ -1,8 +1,10 @@
-# Copyright 2012-2017 Canonical Ltd.  This software is licensed under the
+# Copyright 2012-2018 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Test UEFI custom uploads."""
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 __metaclass__ = type
 
 import os
@@ -255,9 +257,9 @@
         if not os.path.exists(pubconf.temproot):
             os.makedirs(pubconf.temproot)
         self.openArchive("test", "1.0", "amd64")
-        self.tarfile.add_file("1.0/empty.efi", "")
-        self.tarfile.add_file("1.0/empty.ko", "")
-        self.tarfile.add_file("1.0/empty.opal", "")
+        self.tarfile.add_file("1.0/empty.efi", b"")
+        self.tarfile.add_file("1.0/empty.ko", b"")
+        self.tarfile.add_file("1.0/empty.opal", b"")
         upload = self.process_emulate()
         self.assertContentEqual([], upload.callLog.caller_list())
 
@@ -265,9 +267,9 @@
         # If the configured key/cert are missing, processing succeeds but
         # nothing is signed.
         self.openArchive("test", "1.0", "amd64")
-        self.tarfile.add_file("1.0/empty.efi", "")
-        self.tarfile.add_file("1.0/empty.ko", "")
-        self.tarfile.add_file("1.0/empty.opal", "")
+        self.tarfile.add_file("1.0/empty.efi", b"")
+        self.tarfile.add_file("1.0/empty.ko", b"")
+        self.tarfile.add_file("1.0/empty.opal", b"")
         upload = self.process_emulate()
         self.assertContentEqual([], upload.callLog.caller_list())
 
@@ -277,9 +279,9 @@
         self.setUpUefiKeys()
         self.setUpKmodKeys()
         self.openArchive("test", "1.0", "amd64")
-        self.tarfile.add_file("1.0/empty.efi", "")
-        self.tarfile.add_file("1.0/empty.ko", "")
-        self.tarfile.add_file("1.0/empty.opal", "")
+        self.tarfile.add_file("1.0/empty.efi", b"")
+        self.tarfile.add_file("1.0/empty.ko", b"")
+        self.tarfile.add_file("1.0/empty.opal", b"")
         upload = self.process_emulate()
         expected_callers = [
             ('UEFI signing', 1),
@@ -292,9 +294,9 @@
         # nothing is signed.
         self.setUpPPA()
         self.openArchive("test", "1.0", "amd64")
-        self.tarfile.add_file("1.0/empty.efi", "")
-        self.tarfile.add_file("1.0/empty.ko", "")
-        self.tarfile.add_file("1.0/empty.opal", "")
+        self.tarfile.add_file("1.0/empty.efi", b"")
+        self.tarfile.add_file("1.0/empty.ko", b"")
+        self.tarfile.add_file("1.0/empty.opal", b"")
         upload = self.process_emulate()
         expected_callers = [
             ('UEFI keygen', 1),
@@ -352,7 +354,7 @@
         # If the configured key/cert are missing, processing succeeds but
         # nothing is signed.
         self.openArchive("test", "1.0", "amd64")
-        self.tarfile.add_file("1.0/control/options", "")
+        self.tarfile.add_file("1.0/control/options", b"")
         upload = self.process_emulate()
         self.assertContentEqual([], upload.signing_options.keys())
 
@@ -360,7 +362,7 @@
         # If the configured key/cert are missing, processing succeeds but
         # nothing is signed.
         self.openArchive("test", "1.0", "amd64")
-        self.tarfile.add_file("1.0/control/options", "first\n")
+        self.tarfile.add_file("1.0/control/options", b"first\n")
         upload = self.process_emulate()
         self.assertContentEqual(['first'], upload.signing_options.keys())
 
@@ -368,7 +370,7 @@
         # If the configured key/cert are missing, processing succeeds but
         # nothing is signed.
         self.openArchive("test", "1.0", "amd64")
-        self.tarfile.add_file("1.0/control/options", "first\nsecond\n")
+        self.tarfile.add_file("1.0/control/options", b"first\nsecond\n")
         upload = self.process_emulate()
         self.assertContentEqual(['first', 'second'],
             upload.signing_options.keys())
@@ -379,9 +381,9 @@
         self.setUpKmodKeys()
         self.setUpOpalKeys()
         self.openArchive("test", "1.0", "amd64")
-        self.tarfile.add_file("1.0/empty.efi", "")
-        self.tarfile.add_file("1.0/empty.ko", "")
-        self.tarfile.add_file("1.0/empty.opal", "")
+        self.tarfile.add_file("1.0/empty.efi", b"")
+        self.tarfile.add_file("1.0/empty.ko", b"")
+        self.tarfile.add_file("1.0/empty.opal", b"")
         self.process_emulate()
         self.assertThat(self.getSignedPath("test", "amd64"), SignedMatches([
             "1.0/SHA256SUMS",
@@ -397,10 +399,10 @@
         self.setUpKmodKeys()
         self.setUpOpalKeys()
         self.openArchive("test", "1.0", "amd64")
-        self.tarfile.add_file("1.0/control/options", "tarball")
-        self.tarfile.add_file("1.0/empty.efi", "")
-        self.tarfile.add_file("1.0/empty.ko", "")
-        self.tarfile.add_file("1.0/empty.opal", "")
+        self.tarfile.add_file("1.0/control/options", b"tarball")
+        self.tarfile.add_file("1.0/empty.efi", b"")
+        self.tarfile.add_file("1.0/empty.ko", b"")
+        self.tarfile.add_file("1.0/empty.opal", b"")
         self.process_emulate()
         self.assertThat(self.getSignedPath("test", "amd64"), SignedMatches([
             "1.0/SHA256SUMS",
@@ -425,10 +427,10 @@
         self.setUpKmodKeys()
         self.setUpOpalKeys()
         self.openArchive("test", "1.0", "amd64")
-        self.tarfile.add_file("1.0/control/options", "signed-only")
-        self.tarfile.add_file("1.0/empty.efi", "")
-        self.tarfile.add_file("1.0/empty.ko", "")
-        self.tarfile.add_file("1.0/empty.opal", "")
+        self.tarfile.add_file("1.0/control/options", b"signed-only")
+        self.tarfile.add_file("1.0/empty.efi", b"")
+        self.tarfile.add_file("1.0/empty.ko", b"")
+        self.tarfile.add_file("1.0/empty.opal", b"")
         self.process_emulate()
         self.assertThat(self.getSignedPath("test", "amd64"), SignedMatches([
             "1.0/SHA256SUMS", "1.0/control/options",
@@ -445,11 +447,10 @@
         self.setUpKmodKeys()
         self.setUpOpalKeys()
         self.openArchive("test", "1.0", "amd64")
-        self.tarfile.add_file("1.0/control/options",
-            "tarball\nsigned-only")
-        self.tarfile.add_file("1.0/empty.efi", "")
-        self.tarfile.add_file("1.0/empty.ko", "")
-        self.tarfile.add_file("1.0/empty.opal", "")
+        self.tarfile.add_file("1.0/control/options", b"tarball\nsigned-only")
+        self.tarfile.add_file("1.0/empty.efi", b"")
+        self.tarfile.add_file("1.0/empty.ko", b"")
+        self.tarfile.add_file("1.0/empty.opal", b"")
         self.process_emulate()
         self.assertThat(self.getSignedPath("test", "amd64"), SignedMatches([
             "1.0/SHA256SUMS",
@@ -470,7 +471,7 @@
         # Nothing is signed.
         self.setUpUefiKeys()
         self.openArchive("empty", "1.0", "amd64")
-        self.tarfile.add_file("1.0/hello", "world")
+        self.tarfile.add_file("1.0/hello", b"world")
         upload = self.process()
         self.assertTrue(os.path.exists(os.path.join(
             self.getSignedPath("empty", "amd64"), "1.0", "hello")))
@@ -481,7 +482,7 @@
         # If the target directory already exists, processing fails.
         self.setUpUefiKeys()
         self.openArchive("test", "1.0", "amd64")
-        self.tarfile.add_file("1.0/empty.efi", "")
+        self.tarfile.add_file("1.0/empty.efi", b"")
         os.makedirs(os.path.join(self.getSignedPath("test", "amd64"), "1.0"))
         self.assertRaises(CustomUploadAlreadyExists, self.process)
 
@@ -489,7 +490,7 @@
         # The umask must be 0o022 to avoid incorrect permissions.
         self.setUpUefiKeys()
         self.openArchive("test", "1.0", "amd64")
-        self.tarfile.add_file("1.0/dir/file.efi", "foo")
+        self.tarfile.add_file("1.0/dir/file.efi", b"foo")
         os.umask(0o002)  # cleanup already handled by setUp
         self.assertRaises(CustomUploadBadUmask, self.process)
 
@@ -684,7 +685,7 @@
         # Each image in the tarball is signed.
         self.setUpUefiKeys()
         self.openArchive("test", "1.0", "amd64")
-        self.tarfile.add_file("1.0/empty.efi", "")
+        self.tarfile.add_file("1.0/empty.efi", b"")
         upload = self.process()
         self.assertEqual(1, upload.signUefi.call_count)
 
@@ -692,7 +693,7 @@
         # Each image in the tarball is signed.
         self.setUpKmodKeys()
         self.openArchive("test", "1.0", "amd64")
-        self.tarfile.add_file("1.0/empty.ko", "")
+        self.tarfile.add_file("1.0/empty.ko", b"")
         upload = self.process()
         self.assertEqual(1, upload.signKmod.call_count)
 
@@ -700,7 +701,7 @@
         # Each image in the tarball is signed.
         self.setUpOpalKeys()
         self.openArchive("test", "1.0", "amd64")
-        self.tarfile.add_file("1.0/empty.opal", "")
+        self.tarfile.add_file("1.0/empty.opal", b"")
         upload = self.process()
         self.assertEqual(1, upload.signOpal.call_count)
 
@@ -708,12 +709,12 @@
         # Each image in the tarball is signed.
         self.setUpKmodKeys()
         self.openArchive("test", "1.0", "amd64")
-        self.tarfile.add_file("1.0/empty.efi", "")
-        self.tarfile.add_file("1.0/empty.ko", "")
-        self.tarfile.add_file("1.0/empty2.ko", "")
-        self.tarfile.add_file("1.0/empty.opal", "")
-        self.tarfile.add_file("1.0/empty2.opal", "")
-        self.tarfile.add_file("1.0/empty3.opal", "")
+        self.tarfile.add_file("1.0/empty.efi", b"")
+        self.tarfile.add_file("1.0/empty.ko", b"")
+        self.tarfile.add_file("1.0/empty2.ko", b"")
+        self.tarfile.add_file("1.0/empty.opal", b"")
+        self.tarfile.add_file("1.0/empty2.opal", b"")
+        self.tarfile.add_file("1.0/empty3.opal", b"")
         upload = self.process()
         self.assertEqual(1, upload.signUefi.call_count)
         self.assertEqual(2, upload.signKmod.call_count)
@@ -723,7 +724,7 @@
         # Files in the tarball are installed correctly.
         self.setUpUefiKeys()
         self.openArchive("test", "1.0", "amd64")
-        self.tarfile.add_file("1.0/empty.efi", "")
+        self.tarfile.add_file("1.0/empty.efi", b"")
         self.process()
         self.assertTrue(os.path.isdir(os.path.join(
             self.getDistsPath(), "signed")))
@@ -735,7 +736,7 @@
         os.makedirs(os.path.join(self.getDistsPath(), "uefi"))
         self.setUpUefiKeys()
         self.openArchive("test", "1.0", "amd64")
-        self.tarfile.add_file("1.0/empty.efi", "")
+        self.tarfile.add_file("1.0/empty.efi", b"")
         self.process()
         self.assertTrue(os.path.isdir(os.path.join(
             self.getDistsPath(), "signed")))
@@ -747,7 +748,7 @@
         os.makedirs(os.path.join(self.getDistsPath(), "signing"))
         self.setUpUefiKeys()
         self.openArchive("test", "1.0", "amd64")
-        self.tarfile.add_file("1.0/empty.efi", "")
+        self.tarfile.add_file("1.0/empty.efi", b"")
         self.process()
         self.assertTrue(os.path.isdir(os.path.join(
             self.getDistsPath(), "signed")))
@@ -870,9 +871,9 @@
         self.setUpKmodKeys()
         self.setUpOpalKeys()
         self.openArchive("test", "1.0", "amd64")
-        self.tarfile.add_file("1.0/empty.efi", "")
-        self.tarfile.add_file("1.0/empty.ko", "")
-        self.tarfile.add_file("1.0/empty.opal", "")
+        self.tarfile.add_file("1.0/empty.efi", b"")
+        self.tarfile.add_file("1.0/empty.ko", b"")
+        self.tarfile.add_file("1.0/empty.opal", b"")
         self.process_emulate()
         sha256file = os.path.join(self.getSignedPath("test", "amd64"),
              "1.0", "SHA256SUMS")
@@ -888,9 +889,9 @@
         self.setUpKmodKeys()
         self.setUpOpalKeys()
         self.openArchive("test", "1.0", "amd64")
-        self.tarfile.add_file("1.0/empty.efi", "")
-        self.tarfile.add_file("1.0/empty.ko", "")
-        self.tarfile.add_file("1.0/empty.opal", "")
+        self.tarfile.add_file("1.0/empty.efi", b"")
+        self.tarfile.add_file("1.0/empty.ko", b"")
+        self.tarfile.add_file("1.0/empty.opal", b"")
         self.process_emulate()
         sha256file = os.path.join(self.getSignedPath("test", "amd64"),
              "1.0", "SHA256SUMS")
@@ -907,10 +908,10 @@
         self.setUpKmodKeys()
         self.setUpOpalKeys()
         self.openArchive("test", "1.0", "amd64")
-        self.tarfile.add_file("1.0/control/options", "tarball")
-        self.tarfile.add_file("1.0/empty.efi", "")
-        self.tarfile.add_file("1.0/empty.ko", "")
-        self.tarfile.add_file("1.0/empty.opal", "")
+        self.tarfile.add_file("1.0/control/options", b"tarball")
+        self.tarfile.add_file("1.0/empty.efi", b"")
+        self.tarfile.add_file("1.0/empty.ko", b"")
+        self.tarfile.add_file("1.0/empty.opal", b"")
         self.process_emulate()
         sha256file = os.path.join(self.getSignedPath("test", "amd64"),
              "1.0", "SHA256SUMS")
@@ -951,7 +952,7 @@
         # Files in the tarball are installed correctly.
         self.setUpUefiKeys()
         self.openArchive("test", "1.0", "amd64")
-        self.tarfile.add_file("1.0/empty.efi", "")
+        self.tarfile.add_file("1.0/empty.efi", b"")
         self.process()
         self.assertTrue(os.path.isdir(os.path.join(
             self.getDistsPath(), "uefi")))


Follow ups