launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #26315
[Merge] ~cjwatson/launchpad:py3-bytes-literals into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:py3-bytes-literals into launchpad:master.
Commit message:
Explicitly use bytes literals where needed
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/398083
This makes no difference on Python 2, but Python 3 is stricter.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-bytes-literals into launchpad:master.
diff --git a/lib/launchpad_loggerhead/tests.py b/lib/launchpad_loggerhead/tests.py
index c4ebbe0..c712280 100644
--- a/lib/launchpad_loggerhead/tests.py
+++ b/lib/launchpad_loggerhead/tests.py
@@ -50,7 +50,7 @@ class SimpleLogInRootApp(RootApp):
def _complete_login(self, environ, start_response):
environ[SESSION_VAR]['user'] = 'bob'
start_response('200 OK', [('Content-type', 'text/plain')])
- return ['\n']
+ return [b'\n']
def __call__(self, environ, start_response):
codebrowse_netloc = urlsplit(
@@ -60,7 +60,7 @@ class SimpleLogInRootApp(RootApp):
else:
# Return a fake response.
start_response('200 OK', [('Content-type', 'text/plain')])
- return ['This is a dummy destination.\n']
+ return [b'This is a dummy destination.\n']
class TestLogout(TestCase):
@@ -122,7 +122,7 @@ class TestLogout(TestCase):
# Now, though, we are redirected to the ``next_to`` destination.
self.assertEqual(self.browser.url, dummy_root + '+logout')
self.assertEqual(self.browser.contents,
- 'This is a dummy destination.\n')
+ b'This is a dummy destination.\n')
class TestWSGI(TestCaseWithFactory):
diff --git a/lib/lp/archiveuploader/tests/test_uploadprocessor.py b/lib/lp/archiveuploader/tests/test_uploadprocessor.py
index 91ec622..c7020fe 100644
--- a/lib/lp/archiveuploader/tests/test_uploadprocessor.py
+++ b/lib/lp/archiveuploader/tests/test_uploadprocessor.py
@@ -403,15 +403,15 @@ class TestUploadProcessorBase(TestCaseWithFactory):
bar.first().sourcepackagerelease)
changes_file = changes_lfa.read()
self.assertTrue(
- "Format: " in changes_file, "Does not look like a changes file")
+ b"Format: " in changes_file, "Does not look like a changes file")
self.assertTrue(
- "-----BEGIN PGP SIGNED MESSAGE-----" not in changes_file,
+ b"-----BEGIN PGP SIGNED MESSAGE-----" not in changes_file,
"Unexpected PGP header found")
self.assertTrue(
- "-----BEGIN PGP SIGNATURE-----" not in changes_file,
+ b"-----BEGIN PGP SIGNATURE-----" not in changes_file,
"Unexpected start of PGP signature found")
self.assertTrue(
- "-----END PGP SIGNATURE-----" not in changes_file,
+ b"-----END PGP SIGNATURE-----" not in changes_file,
"Unexpected end of PGP signature found")
@@ -2278,10 +2278,9 @@ class TestUploadHandler(TestUploadProcessorBase):
self.assertEqual(builder, build.builder)
self.assertIsNot(None, build.duration)
log_contents = build.upload_log.read()
- self.assertTrue('ERROR Exception while processing upload '
- in log_contents)
- self.assertFalse('DEBUG Moving upload directory '
- in log_contents)
+ self.assertIn(
+ b'ERROR Exception while processing upload ', log_contents)
+ self.assertNotIn(b'DEBUG Moving upload directory ', log_contents)
def testBinaryPackageBuilds(self):
# Properly uploaded binaries should result in the
diff --git a/lib/lp/buildmaster/tests/mock_slaves.py b/lib/lp/buildmaster/tests/mock_slaves.py
index f2cf744..260980d 100644
--- a/lib/lp/buildmaster/tests/mock_slaves.py
+++ b/lib/lp/buildmaster/tests/mock_slaves.py
@@ -163,7 +163,7 @@ class BuildingSlave(OkSlave):
def status(self):
self.call_log.append('status')
buildlog = xmlrpc_client.Binary(
- "This is a build log: %d" % self.status_count)
+ b"This is a build log: %d" % self.status_count)
self.status_count += 1
return defer.succeed({
'builder_status': 'BuilderStatus.BUILDING',
diff --git a/lib/lp/code/model/tests/test_branchjob.py b/lib/lp/code/model/tests/test_branchjob.py
index 2abb78a..d2f6470 100644
--- a/lib/lp/code/model/tests/test_branchjob.py
+++ b/lib/lp/code/model/tests/test_branchjob.py
@@ -1285,7 +1285,7 @@ class TestViaCelery(TestCaseWithFactory):
db_branch = self.factory.makeAnyBranch()
self.createBzrBranch(db_branch)
commit = DirectBranchCommit(db_branch, no_race_check=True)
- commit.writeFile('foo.pot', 'gibberish')
+ commit.writeFile('foo.pot', b'gibberish')
with person_logged_in(db_branch.owner):
# wait for branch scan
with block_on_job(self):
diff --git a/lib/lp/code/tests/test_branch_webservice.py b/lib/lp/code/tests/test_branch_webservice.py
index 7be0147..9f41d98 100644
--- a/lib/lp/code/tests/test_branch_webservice.py
+++ b/lib/lp/code/tests/test_branch_webservice.py
@@ -116,7 +116,7 @@ class TestBranchOperations(TestCaseWithFactory):
reviewers=[source.owner.self_link], review_types=[])
self.assertEqual(
exception.content,
- 'reviewers and review_types must be equal length.')
+ b'reviewers and review_types must be equal length.')
def test_getBranchVisibilityInfo(self):
"""Test the test_getBranchVisibilityInfo API."""
@@ -150,7 +150,7 @@ class TestBranchOperations(TestCaseWithFactory):
needs_review=True, commit_message='It was merged!\n')
self.assertEqual(
exception.content,
- 'Source and target branches must be different.')
+ b'Source and target branches must be different.')
def test_setOwner(self):
"""Test setOwner via the web API does not raise a 404."""
@@ -209,7 +209,7 @@ class TestBranchDeletes(TestCaseWithFactory):
target_branch = self.lp.branches.getByUniqueName(
unique_name='~jimhenson/fraggle/rock')
api_error = self.assertRaises(BadRequest, target_branch.lp_delete)
- self.assertIn('Cannot delete', api_error.content)
+ self.assertIn(b'Cannot delete', api_error.content)
class TestSlashBranches(TestCaseWithFactory):
diff --git a/lib/lp/codehosting/scanner/tests/test_bzrsync.py b/lib/lp/codehosting/scanner/tests/test_bzrsync.py
index 3c49360..0e1a9d8 100644
--- a/lib/lp/codehosting/scanner/tests/test_bzrsync.py
+++ b/lib/lp/codehosting/scanner/tests/test_bzrsync.py
@@ -703,7 +703,7 @@ class TestGenerateIncrementalDiffJob(BzrSyncTestCase):
@run_as_db_user(config.launchpad.dbuser)
def test_create_on_new_revision(self):
"""When branch tip changes, a job is created."""
- parent_id = commit_file(self.db_branch, 'foo', 'bar')
+ parent_id = commit_file(self.db_branch, 'foo', b'bar')
self.factory.makeBranchRevision(self.db_branch, parent_id,
revision_date=self.factory.getUniqueDate())
self.db_branch.last_scanned_id = parent_id
@@ -713,7 +713,7 @@ class TestGenerateIncrementalDiffJob(BzrSyncTestCase):
bmp = self.factory.makeBranchMergeProposal(
source_branch=self.db_branch,
date_created=date_created)
- revision_id = commit_file(self.db_branch, 'foo', 'baz')
+ revision_id = commit_file(self.db_branch, 'foo', b'baz')
removeSecurityProxy(bmp).target_branch.last_scanned_id = 'rev'
self.assertEqual([], self.getPending())
switch_dbuser("branchscanner")
diff --git a/lib/lp/codehosting/tests/test_lpserve.py b/lib/lp/codehosting/tests/test_lpserve.py
index a190816..307a401 100644
--- a/lib/lp/codehosting/tests/test_lpserve.py
+++ b/lib/lp/codehosting/tests/test_lpserve.py
@@ -29,7 +29,7 @@ class TestLaunchpadServe(TestCaseWithSubprocess):
def assertFinishedCleanly(self, result):
"""Assert that a server process finished cleanly."""
- self.assertEqual((0, '', ''), tuple(result))
+ self.assertEqual((0, b'', b''), tuple(result))
def finish_lpserve_subprocess(self, process):
"""Shut down the server process.
diff --git a/lib/lp/registry/browser/tests/test_rdf.py b/lib/lp/registry/browser/tests/test_rdf.py
index 11b9206..390989c 100644
--- a/lib/lp/registry/browser/tests/test_rdf.py
+++ b/lib/lp/registry/browser/tests/test_rdf.py
@@ -29,8 +29,8 @@ class TestRootRDF(TestCaseWithFactory):
app = getUtility(ILaunchpadApplication)
view = create_view(app, name='rdf-spec')
owl = view.publishTraverse(view.request, 'launchpad.owl')
- entity = 'ENTITY launchpad "https://launchpad.net/rdf-spec/launchpad#'
- self.assertTrue(entity in owl())
+ entity = b'ENTITY launchpad "https://launchpad.net/rdf-spec/launchpad#'
+ self.assertIn(entity, owl())
self.assertEqual(
'application/rdf+xml',
owl.request.response.getHeader('content-type'))
diff --git a/lib/lp/registry/tests/test_codeofconduct.py b/lib/lp/registry/tests/test_codeofconduct.py
index b505254..e8b2bd3 100644
--- a/lib/lp/registry/tests/test_codeofconduct.py
+++ b/lib/lp/registry/tests/test_codeofconduct.py
@@ -108,7 +108,7 @@ class TestSignedCodeOfConductSet(TestCaseWithFactory):
def test_verifyAndStore_unregistered(self):
fingerprint = "0" * 40
- signature = PymeSignature(fingerprint, "plain data")
+ signature = PymeSignature(fingerprint, b"plain data")
self.useFixture(ZopeUtilityFixture(
FakeGPGHandlerGood(signature), IGPGHandler))
user = self.factory.makePerson()
@@ -120,7 +120,7 @@ class TestSignedCodeOfConductSet(TestCaseWithFactory):
def test_verifyAndStore_wrong_owner(self):
other_user = self.factory.makePerson()
gpgkey = self.factory.makeGPGKey(other_user)
- signature = PymeSignature(gpgkey.fingerprint, "plain data")
+ signature = PymeSignature(gpgkey.fingerprint, b"plain data")
self.useFixture(ZopeUtilityFixture(
FakeGPGHandlerGood(signature), IGPGHandler))
user = self.factory.makePerson()
@@ -133,7 +133,7 @@ class TestSignedCodeOfConductSet(TestCaseWithFactory):
user = self.factory.makePerson()
gpgkey = self.factory.makeGPGKey(user)
gpgkey.active = False
- signature = PymeSignature(gpgkey.fingerprint, "plain data")
+ signature = PymeSignature(gpgkey.fingerprint, b"plain data")
self.useFixture(ZopeUtilityFixture(
FakeGPGHandlerGood(signature), IGPGHandler))
self.assertThat(
@@ -144,7 +144,7 @@ class TestSignedCodeOfConductSet(TestCaseWithFactory):
def test_verifyAndStore_bad_plain_data(self):
user = self.factory.makePerson()
gpgkey = self.factory.makeGPGKey(user)
- signature = PymeSignature(gpgkey.fingerprint, "plain data")
+ signature = PymeSignature(gpgkey.fingerprint, b"plain data")
self.useFixture(ZopeUtilityFixture(
FakeGPGHandlerGood(signature), IGPGHandler))
self.assertThat(
diff --git a/lib/lp/registry/tests/test_project_milestone.py b/lib/lp/registry/tests/test_project_milestone.py
index 7819b15..cf14ffa 100644
--- a/lib/lp/registry/tests/test_project_milestone.py
+++ b/lib/lp/registry/tests/test_project_milestone.py
@@ -351,4 +351,4 @@ class TestDuplicateProductReleases(TestCaseWithFactory):
self.assertEqual([], self.oopses)
self.assertEqual(400, e.response.status)
self.assertIn(
- 'A milestone can only have one ProductRelease.', e.content)
+ b'A milestone can only have one ProductRelease.', e.content)
diff --git a/lib/lp/registry/tests/test_projectgroup.py b/lib/lp/registry/tests/test_projectgroup.py
index 9edca88..6ef7c65 100644
--- a/lib/lp/registry/tests/test_projectgroup.py
+++ b/lib/lp/registry/tests/test_projectgroup.py
@@ -227,5 +227,5 @@ class TestLaunchpadlibAPI(TestCaseWithFactory):
self.assertEqual([], self.oopses)
self.assertEqual(400, e.response.status)
self.assertIn(
- 'This project cannot be deactivated since it is linked to source '
- 'packages.', e.content)
+ b'This project cannot be deactivated since it is linked to source '
+ b'packages.', e.content)
diff --git a/lib/lp/scripts/tests/test_garbo.py b/lib/lp/scripts/tests/test_garbo.py
index abbfe97..f7a995f 100644
--- a/lib/lp/scripts/tests/test_garbo.py
+++ b/lib/lp/scripts/tests/test_garbo.py
@@ -1173,9 +1173,9 @@ class TestGarbo(FakeAdapterMixin, TestCaseWithFactory):
self.assertEqual(0, len(list(store.find(TimeLimitedToken,
path="sample path"))))
# One to clean and one to keep
- store.add(TimeLimitedToken(path="sample path", token="foo",
+ store.add(TimeLimitedToken(path="sample path", token=b"foo",
created=datetime(2008, 1, 1, tzinfo=UTC)))
- store.add(TimeLimitedToken(path="sample path", token="bar")),
+ store.add(TimeLimitedToken(path="sample path", token=b"bar")),
store.commit()
self.assertEqual(2, len(list(store.find(TimeLimitedToken,
path="sample path"))))
diff --git a/lib/lp/services/config/tests/test_config_lookup.py b/lib/lp/services/config/tests/test_config_lookup.py
index 6c41492..8c160ab 100644
--- a/lib/lp/services/config/tests/test_config_lookup.py
+++ b/lib/lp/services/config/tests/test_config_lookup.py
@@ -33,7 +33,7 @@ class TestConfigLookup(TestCase):
def makeLookupFile(self):
self.temp_lookup_file = NamedTemporaryFile()
- self.temp_lookup_file.write('\nfrom_disk \n')
+ self.temp_lookup_file.write(b'\nfrom_disk \n')
self.temp_lookup_file.flush()
config.CONFIG_LOOKUP_FILES = [
NamedTemporaryFile().name, self.temp_lookup_file.name]
diff --git a/lib/lp/services/librarian/tests/test_client.py b/lib/lp/services/librarian/tests/test_client.py
index a9475b2..a5528f9 100644
--- a/lib/lp/services/librarian/tests/test_client.py
+++ b/lib/lp/services/librarian/tests/test_client.py
@@ -305,7 +305,7 @@ class LibrarianClientTestCase(TestCase):
'sample.txt', 6, io.BytesIO(b'sample'), 'text/plain')
transaction.commit()
f = client.getFileByAlias(alias_id)
- self.assertEqual(f.read(), 'sample')
+ self.assertEqual(f.read(), b'sample')
def test_addFile_no_response_check_at_end_headers_for_empty_file(self):
# When addFile() sends the request header, it checks if the
@@ -432,7 +432,7 @@ class LibrarianClientTestCase(TestCase):
self.assertFalse(client.called_getURLForDownload)
# (Test:)
f = client.getFileByAlias(alias_id)
- self.assertEqual(f.read(), 'sample')
+ self.assertEqual(f.read(), b'sample')
self.assertTrue(client.called_getURLForDownload)
def test_getFileByAliasLookupError(self):
diff --git a/lib/lp/services/openid/tests/test_baseopenidstore.py b/lib/lp/services/openid/tests/test_baseopenidstore.py
index 52babaa..8fab4d2 100644
--- a/lib/lp/services/openid/tests/test_baseopenidstore.py
+++ b/lib/lp/services/openid/tests/test_baseopenidstore.py
@@ -25,28 +25,28 @@ class BaseStormOpenIDStoreTestsMixin:
self.assertIsInstance(self.store, BaseStormOpenIDStore)
def test_storeAssociation(self):
- self.store.storeAssociation('server-url\xC2\xA9', Association(
- 'handle', 'secret', 42, 600, 'HMAC-SHA1'))
+ self.store.storeAssociation(u'server-url\xA9', Association(
+ b'handle', b'secret', 42, 600, 'HMAC-SHA1'))
db_assoc = IMasterStore(self.store.Association).get(
self.store.Association, (u'server-url\xA9', u'handle'))
self.assertEqual(db_assoc.server_url, u'server-url\xA9')
self.assertEqual(db_assoc.handle, u'handle')
- self.assertEqual(db_assoc.secret, 'secret')
+ self.assertEqual(db_assoc.secret, b'secret')
self.assertEqual(db_assoc.issued, 42)
self.assertEqual(db_assoc.lifetime, 600)
self.assertEqual(db_assoc.assoc_type, u'HMAC-SHA1')
def test_storeAssociation_update_existing(self):
self.store.storeAssociation('server-url', Association(
- 'handle', 'secret', 42, 600, 'HMAC-SHA1'))
+ b'handle', b'secret', 42, 600, 'HMAC-SHA1'))
db_assoc = IMasterStore(self.store.Association).get(
self.store.Association, (u'server-url', u'handle'))
self.assertNotEqual(db_assoc, None)
# Now update the association with new information.
self.store.storeAssociation('server-url', Association(
- 'handle', 'secret2', 420, 900, 'HMAC-SHA256'))
- self.assertEqual(db_assoc.secret, 'secret2')
+ b'handle', b'secret2', 420, 900, 'HMAC-SHA256'))
+ self.assertEqual(db_assoc.secret, b'secret2')
self.assertEqual(db_assoc.issued, 420)
self.assertEqual(db_assoc.lifetime, 900)
self.assertEqual(db_assoc.assoc_type, u'HMAC-SHA256')
@@ -54,12 +54,12 @@ class BaseStormOpenIDStoreTestsMixin:
def test_getAssociation(self):
timestamp = int(time.time())
self.store.storeAssociation('server-url', Association(
- 'handle', 'secret', timestamp, 600, 'HMAC-SHA1'))
+ b'handle', b'secret', timestamp, 600, 'HMAC-SHA1'))
assoc = self.store.getAssociation('server-url', 'handle')
self.assertIsInstance(assoc, Association)
self.assertEqual(assoc.handle, 'handle')
- self.assertEqual(assoc.secret, 'secret')
+ self.assertEqual(assoc.secret, b'secret')
self.assertEqual(assoc.issued, timestamp)
self.assertEqual(assoc.lifetime, 600)
self.assertEqual(assoc.assoc_type, 'HMAC-SHA1')
@@ -72,7 +72,7 @@ class BaseStormOpenIDStoreTestsMixin:
lifetime = 600
timestamp = int(time.time()) - 2 * lifetime
self.store.storeAssociation('server-url', Association(
- 'handle', 'secret', timestamp, lifetime, 'HMAC-SHA1'))
+ b'handle', b'secret', timestamp, lifetime, 'HMAC-SHA1'))
# The association is not returned because it is out of date.
# Further more, it is removed from the database.
assoc = self.store.getAssociation('server-url', 'handle')
@@ -86,9 +86,9 @@ class BaseStormOpenIDStoreTestsMixin:
def test_getAssociation_no_handle(self):
timestamp = int(time.time())
self.store.storeAssociation('server-url', Association(
- 'handle1', 'secret', timestamp, 600, 'HMAC-SHA1'))
+ b'handle1', b'secret', timestamp, 600, 'HMAC-SHA1'))
self.store.storeAssociation('server-url', Association(
- 'handle2', 'secret', timestamp + 1, 600, 'HMAC-SHA1'))
+ b'handle2', b'secret', timestamp + 1, 600, 'HMAC-SHA1'))
# The most recent handle is returned.
assoc = self.store.getAssociation('server-url', None)
@@ -98,7 +98,7 @@ class BaseStormOpenIDStoreTestsMixin:
def test_removeAssociation(self):
timestamp = int(time.time())
self.store.storeAssociation('server-url', Association(
- 'handle', 'secret', timestamp, 600, 'HMAC-SHA1'))
+ b'handle', b'secret', timestamp, 600, 'HMAC-SHA1'))
self.assertEqual(
self.store.removeAssociation('server-url', 'handle'), True)
self.assertEqual(
@@ -137,9 +137,9 @@ class BaseStormOpenIDStoreTestsMixin:
def test_cleanupAssociations(self):
timestamp = int(time.time()) - 100
self.store.storeAssociation('server-url', Association(
- 'handle1', 'secret', timestamp, 50, 'HMAC-SHA1'))
+ b'handle1', b'secret', timestamp, 50, 'HMAC-SHA1'))
self.store.storeAssociation('server-url', Association(
- 'handle2', 'secret', timestamp, 200, 'HMAC-SHA1'))
+ b'handle2', b'secret', timestamp, 200, 'HMAC-SHA1'))
self.assertEqual(self.store.cleanupAssociations(), 1)
diff --git a/lib/lp/services/twistedsupport/tests/test_gracefulshutdown.py b/lib/lp/services/twistedsupport/tests/test_gracefulshutdown.py
index 4097bf3..27de34e 100644
--- a/lib/lp/services/twistedsupport/tests/test_gracefulshutdown.py
+++ b/lib/lp/services/twistedsupport/tests/test_gracefulshutdown.py
@@ -118,7 +118,7 @@ class TestServerAvailableResource(TestCase):
request = self.make_dummy_http_request()
body = r.render_GET(request)
self.assertEqual(200, request.code)
- self.assertTrue(body.startswith('Available\n'))
+ self.assertTrue(body.startswith(b'Available\n'))
def test_503_after_shutdown_starts(self):
"""
@@ -135,7 +135,7 @@ class TestServerAvailableResource(TestCase):
request = self.make_dummy_http_request()
body = r.render_GET(request)
self.assertEqual(503, request.code)
- self.assertTrue(body.startswith('Unavailable\n'))
+ self.assertTrue(body.startswith(b'Unavailable\n'))
class TestService(service.Service):
diff --git a/lib/lp/services/webservice/tests/test_wadl_generation.py b/lib/lp/services/webservice/tests/test_wadl_generation.py
index 553254e..808e1f1 100644
--- a/lib/lp/services/webservice/tests/test_wadl_generation.py
+++ b/lib/lp/services/webservice/tests/test_wadl_generation.py
@@ -28,11 +28,11 @@ class SmokeTestWadlAndDocGeneration(TestCase):
config = getUtility(IWebServiceConfiguration)
for version in config.active_versions:
wadl = generate_wadl(version)
- self.assertThat(wadl[:40], StartsWith('<?xml '))
+ self.assertThat(wadl[:40], StartsWith(b'<?xml '))
WebServiceApplication.cached_wadl = preexisting_wadl_cache
def test_json(self):
config = getUtility(IWebServiceConfiguration)
for version in config.active_versions:
json = generate_json(version)
- self.assertThat(json, StartsWith('{"'))
+ self.assertThat(json, StartsWith(b'{"'))
diff --git a/lib/lp/soyuz/browser/tests/test_distroarchseries_webservice.py b/lib/lp/soyuz/browser/tests/test_distroarchseries_webservice.py
index 8766959..176449b 100644
--- a/lib/lp/soyuz/browser/tests/test_distroarchseries_webservice.py
+++ b/lib/lp/soyuz/browser/tests/test_distroarchseries_webservice.py
@@ -103,7 +103,7 @@ class TestDistroArchSeriesWebservice(TestCaseWithFactory):
ws_das = ws_object(webservice, das)
e = self.assertRaises(
BadRequest, ws_das.setChroot, data=b'zyx', sha1sum='x')
- self.assertEqual("Chroot upload checksums do not match", e.content)
+ self.assertEqual(b"Chroot upload checksums do not match", e.content)
def test_setChroot_missing_trailing_cr(self):
# Due to http://bugs.python.org/issue1349106 launchpadlib sends
@@ -272,7 +272,7 @@ class TestDistroArchSeriesWebservice(TestCaseWithFactory):
e = self.assertRaises(
BadRequest, ws_das.setChrootFromBuild,
livefsbuild=build_url, filename="livecd.ubuntu-base.rootfs.tar.gz")
- self.assertEqual("Cannot set chroot from a private build.", e.content)
+ self.assertEqual(b"Cannot set chroot from a private build.", e.content)
def test_setChrootFromBuild_pocket(self):
self.useFixture(FeatureFixture({LIVEFS_FEATURE_FLAG: "on"}))
diff --git a/lib/lp/soyuz/model/distroarchseries.py b/lib/lp/soyuz/model/distroarchseries.py
index cc70bc8..0bee6c1 100644
--- a/lib/lp/soyuz/model/distroarchseries.py
+++ b/lib/lp/soyuz/model/distroarchseries.py
@@ -218,7 +218,7 @@ class DistroArchSeries(SQLBase):
# match.
content_sha1sum = hashlib.sha1(filecontent).hexdigest()
if content_sha1sum != sha1sum:
- filecontent += '\r'
+ filecontent += b'\r'
content_sha1sum = hashlib.sha1(filecontent).hexdigest()
if content_sha1sum != sha1sum:
raise InvalidChrootUploaded("Chroot upload checksums do not match")
diff --git a/lib/lp/soyuz/tests/test_archivefile.py b/lib/lp/soyuz/tests/test_archivefile.py
index 039fec6..c1d89e3 100644
--- a/lib/lp/soyuz/tests/test_archivefile.py
+++ b/lib/lp/soyuz/tests/test_archivefile.py
@@ -54,7 +54,7 @@ class TestArchiveFile(TestCaseWithFactory):
self.assertEqual("dists/foo", archive_file.path)
archive_file.library_file.open()
try:
- self.assertEqual("abc\n", archive_file.library_file.read())
+ self.assertEqual(b"abc\n", archive_file.library_file.read())
finally:
archive_file.library_file.close()
self.assertIsNone(archive_file.scheduled_deletion_date)
diff --git a/lib/lp/testing/xmlrpc.py b/lib/lp/testing/xmlrpc.py
index 5eb8ab3..7666680 100644
--- a/lib/lp/testing/xmlrpc.py
+++ b/lib/lp/testing/xmlrpc.py
@@ -43,7 +43,7 @@ class TestHTTPConnection(http_client.HTTPConnection):
Only the methods called by xmlrpc_client are overridden.
"""
- _data_to_send = ''
+ _data_to_send = b''
_response = None
def connect(self):
diff --git a/lib/lp/translations/scripts/tests/test_reupload_translations.py b/lib/lp/translations/scripts/tests/test_reupload_translations.py
index ea3898a..a802b42 100644
--- a/lib/lp/translations/scripts/tests/test_reupload_translations.py
+++ b/lib/lp/translations/scripts/tests/test_reupload_translations.py
@@ -156,8 +156,8 @@ class TestReuploadPackageTranslations(TestCaseWithFactory):
# _processPackage will fetch the package's latest translations
# upload from the Librarian and re-import it.
translation_files = {
- 'source/po/messages.pot': '# pot',
- 'source/po/nl.po': '# nl',
+ 'source/po/messages.pot': b'# pot',
+ 'source/po/nl.po': b'# nl',
}
queue_summary = self._uploadAndProcess(translation_files)
self.assertEqual(filter_paths(translation_files), queue_summary)
@@ -165,11 +165,11 @@ class TestReuploadPackageTranslations(TestCaseWithFactory):
def test_processPackage_filters_paths(self):
# Uploads are filtered just like other Ubuntu tarballs.
translation_files = {
- 'source/foo.pot': '# foo',
- 'elsewhere/bar.pot': '# bar',
+ 'source/foo.pot': b'# foo',
+ 'elsewhere/bar.pot': b'# bar',
}
queue_summary = self._uploadAndProcess(translation_files)
- self.assertEqual({'foo.pot': '# foo'}, queue_summary)
+ self.assertEqual({'foo.pot': b'# foo'}, queue_summary)
class TestReuploadScript(TestCaseWithFactory):
diff --git a/lib/lp/translations/tests/test_translationtemplatesbuild.py b/lib/lp/translations/tests/test_translationtemplatesbuild.py
index c5f28af..949ea7e 100644
--- a/lib/lp/translations/tests/test_translationtemplatesbuild.py
+++ b/lib/lp/translations/tests/test_translationtemplatesbuild.py
@@ -182,7 +182,7 @@ class TestTranslationTemplatesBuild(TestCaseWithFactory):
branch = self._makeTranslationBranch()
removeSecurityProxy(branch).last_scanned_id = 'null:'
commit = DirectBranchCommit(branch)
- commit.writeFile('POTFILES.in', 'foo')
+ commit.writeFile('POTFILES.in', b'foo')
commit.commit('message')
notify(events.TipChanged(branch, commit.bzrbranch, False))
self.assertEqual(
diff --git a/lib/lp/translations/utilities/tests/test_export_file_storage.py b/lib/lp/translations/utilities/tests/test_export_file_storage.py
index 182bfbe..0cf05df 100644
--- a/lib/lp/translations/utilities/tests/test_export_file_storage.py
+++ b/lib/lp/translations/utilities/tests/test_export_file_storage.py
@@ -54,7 +54,7 @@ class ExportFileStorageTestCase(unittest.TestCase):
outfile = storage.export()
self.assertEqual(outfile.path, '/tmp/a/test/file.po')
self.assertEqual(outfile.file_extension, 'po')
- self.assertEqual(outfile.read(), 'test file')
+ self.assertEqual(outfile.read(), b'test file')
def testTarball(self):
"""Test export of tarball."""