Colin Watson has proposed merging
lp:~cjwatson/launchpad/soyuz-tests-future-imports into lp:launchpad with
lp:~cjwatson/launchpad/soyuz-browser-tests-future-imports as a prerequisite.
Commit message:
Convert lp.soyuz.tests to Launchpad's preferred __future__ imports.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/soyuz-tests-future-imports/+merge/337042
Long but boring. The only wart was needing to fix a couple of type(foo) == str
checks.
--
Your team Launchpad code reviewers is requested to review the proposed merge of
lp:~cjwatson/launchpad/soyuz-tests-future-imports into lp:launchpad.
=== modified file 'lib/lp/soyuz/tests/fakepackager.py'
--- lib/lp/soyuz/tests/fakepackager.py 2017-07-31 11:45:32 +
+++ lib/lp/soyuz/tests/fakepackager.py 2018-02-02 10:33:11 +
@@ -1,4 +1,4 @@
-# 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).
"""FakePackager utility.
@@ -7,6 +7,8 @@
suite.
"""
+from __future__ import absolute_import, print_function, unicode_literals
+
__metaclass__ = type
__all__ = ['FakePackager']
=== modified file 'lib/lp/soyuz/tests/soyuz.py'
--- lib/lp/soyuz/tests/soyuz.py 2017-06-14 02:44:33 +
+++ lib/lp/soyuz/tests/soyuz.py 2018-02-02 10:33:11 +
@@ -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).
"""Helper functions/classes for Soyuz tests."""
+from __future__ import absolute_import, print_function, unicode_literals
+
__metaclass__ = type
__all__ = [
=== modified file 'lib/lp/soyuz/tests/test_archive.py'
--- lib/lp/soyuz/tests/test_archive.py 2017-04-29 23:51:28 +
+++ lib/lp/soyuz/tests/test_archive.py 2018-02-02 10:33:11 +
@@ -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 Archive features."""
+from __future__ import absolute_import, print_function, unicode_literals
+
from datetime import (
date,
datetime,
@@ -12,6 +14,7 @@
import os.path
from pytz import UTC
+import six
from testtools.deferredruntest import AsynchronousDeferredRunTest
from testtools.matchers import (
AllMatch,
@@ -1272,15 +1275,15 @@
def test_feature_flag_disabled(self):
# With feature flag disabled, we will not create new named auth tokens.
private_ppa = self.factory.makeArchive(private=True)
-with FeatureFixture({NAMED_AUTH_TOKEN_FEATURE_FLAG: u""}):
+with FeatureFixture({NAMED_AUTH_TOKEN_FEATURE_FLAG: ""}):
self.assertRaises(NamedAuthTokenFeatureDisabled,
- private_ppa.newNamedAuthToken, u"tokenname")
+ private_ppa.newNamedAuthToken, "tokenname")
def test_feature_flag_disabled_by_default(self):
# Without a feature flag, we will not create new named auth tokens.
private_ppa = self.factory.makeArchive(private=True)
self.assertRaises(NamedAuthTokenFeatureDisabled,
-private_ppa.newNamedAuthToken, u"tokenname")
+private_ppa.newNamedAuthToken, "tokenname")
class TestArchiveTokens(TestCaseWithFactory):
@@ -1292,7 +1295,7 @@
self.private_ppa = self.factory.makeArchive(owner=owner, private=True)
self.joe = self.factory.makePerson(name='joe')
self.private_ppa.newSubscription(self.joe, owner)
-self.useFixture(FeatureFixture({NAMED_AUTH_TOKEN_FEATURE_FLAG: u"on"}))
+self.useFixture(FeatureFixture({NAMED_AUTH_TOKEN_FEATURE_FLAG: "on"}))
def test_getAuthToken_with_no_token(self):
self.assertIsNone(self.private_ppa.getAuthToken(self.joe))
@@ -1308,8 +1311,8 @@
self.assertEqual(token.archive_url, url)
def test_newNamedAuthToken_private_archive(self):
-res = self.private_ppa.newNamedAuthToken(u"tokenname", as_dict=True)
-token = self.private_ppa.getNamedAuthToken(u"tokenname")
+res = self.private_ppa.newNamedAuthToken("tokenname", as_dict=True)
+token = self.private_ppa.getNamedAuthToken("tokenname")
self.assertIsNotNone(token)
self.assertIsNone(token.person)
self.assertEqual("tokenname", token.name)
@@ -1325,37 +1328,37 @@
def test_newNamedAuthToken_public_archive(self):
public_ppa = self.factory.makeArchive(private=False)
self.assertRaises(ArchiveNotPrivate,
-public_ppa.newNamedAuthToken, u"tokenname")
+public_ppa.newNamedAuthToken, "tokenname")
def