← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:py3-response-body-bytes into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:py3-response-body-bytes into launchpad:master.

Commit message:
Adjust response.body assertions to expect bytes

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/395708
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-response-body-bytes into launchpad:master.
diff --git a/lib/lp/app/webservice/tests/test_marshallers.py b/lib/lp/app/webservice/tests/test_marshallers.py
index 9b14052..e689d96 100644
--- a/lib/lp/app/webservice/tests/test_marshallers.py
+++ b/lib/lp/app/webservice/tests/test_marshallers.py
@@ -117,9 +117,9 @@ class TestWebServiceObfuscation(TestCaseWithFactory):
         webservice = webservice_for_person(user)
         result = webservice(
             ws_url(bug), headers={'Accept': 'application/xhtml+xml'})
-        self.assertIn(self.email_address, result.body)
+        self.assertIn(self.email_address.encode('UTF-8'), result.body)
         self.assertNotIn(
-            self.email_address_obfuscated_escaped, result.body)
+            self.email_address_obfuscated_escaped.encode('UTF-8'), result.body)
 
     def test_xhtml_email_address_obfuscated(self):
         # Email addresses are obfuscated in the XML representation for
@@ -129,8 +129,9 @@ class TestWebServiceObfuscation(TestCaseWithFactory):
         webservice = LaunchpadWebServiceCaller()
         result = webservice(
             ws_url(bug), headers={'Accept': 'application/xhtml+xml'})
-        self.assertNotIn(self.email_address, result.body)
-        self.assertIn(self.email_address_obfuscated_escaped, result.body)
+        self.assertNotIn(self.email_address.encode('UTF-8'), result.body)
+        self.assertIn(
+            self.email_address_obfuscated_escaped.encode('UTF-8'), result.body)
 
     def test_etags_differ_for_anon_and_non_anon_represetations(self):
         # When a webservice client retrieves data anonymously, this
diff --git a/lib/lp/blueprints/tests/test_webservice.py b/lib/lp/blueprints/tests/test_webservice.py
index 3235b05..7ff1ce7 100644
--- a/lib/lp/blueprints/tests/test_webservice.py
+++ b/lib/lp/blueprints/tests/test_webservice.py
@@ -332,7 +332,8 @@ class SpecificationMutationTests(TestCaseWithFactory):
             json.dumps(dict(target_link=new_target_url)), api_version='devel')
         self.assertEqual(400, response.status)
         self.assertEqual(
-            "There is already a blueprint named foo for Fooix.", response.body)
+            b"There is already a blueprint named foo for Fooix.",
+            response.body)
 
 
 class SpecificationTargetTests(TestCaseWithFactory):
diff --git a/lib/lp/bugs/tests/test_bugs_webservice.py b/lib/lp/bugs/tests/test_bugs_webservice.py
index 2c87319..099c5ca 100644
--- a/lib/lp/bugs/tests/test_bugs_webservice.py
+++ b/lib/lp/bugs/tests/test_bugs_webservice.py
@@ -18,6 +18,7 @@ from lazr.restfulclient.errors import (
     )
 import pytz
 from simplejson import dumps
+import six
 from storm.store import Store
 from testtools.matchers import (
     Equals,
@@ -187,7 +188,7 @@ class TestBugCommentRepresentation(TestCaseWithFactory):
 
         self.assertEqual(response.status, 200)
 
-        rendered_comment = response.body
+        rendered_comment = six.ensure_text(response.body)
         self.assertRenderedCommentsEqual(
             rendered_comment, self.expected_comment_html)
 
diff --git a/lib/lp/code/model/tests/test_gitrepository.py b/lib/lp/code/model/tests/test_gitrepository.py
index b83f9da..5edbcf7 100644
--- a/lib/lp/code/model/tests/test_gitrepository.py
+++ b/lib/lp/code/model/tests/test_gitrepository.py
@@ -4503,8 +4503,8 @@ class TestGitRepositoryWebservice(TestCaseWithFactory):
         response = webservice.named_post(repository_url, "issueAccessToken")
         self.assertEqual(401, response.status)
         self.assertEqual(
-            "git-repository macaroons may only be issued for a logged-in "
-            "user.", response.body)
+            b"git-repository macaroons may only be issued for a logged-in "
+            b"user.", response.body)
 
 
 class TestGitRepositoryMacaroonIssuer(MacaroonTestMixin, TestCaseWithFactory):
diff --git a/lib/lp/registry/browser/tests/test_person_webservice.py b/lib/lp/registry/browser/tests/test_person_webservice.py
index e764da5..e161a44 100644
--- a/lib/lp/registry/browser/tests/test_person_webservice.py
+++ b/lib/lp/registry/browser/tests/test_person_webservice.py
@@ -160,7 +160,7 @@ class TestPersonRepresentation(TestCaseWithFactory):
         rendered_comment = response.body
         self.assertEqual(
             rendered_comment,
-            '<a href="/~test-person" class="sprite person">Test Person</a>')
+            b'<a href="/~test-person" class="sprite person">Test Person</a>')
 
 
 class PersonWebServiceTests(TestCaseWithFactory):
@@ -499,23 +499,23 @@ class PersonSetWebServiceTests(TestCaseWithFactory):
             sso, 'foo', 'taken-name', dry_run=dry_run)
         self.assertEqual(400, response.status)
         self.assertEqual(
-            'name: taken-name is already in use by another person or team.',
+            b'name: taken-name is already in use by another person or team.',
             response.body)
 
         response = self.setUsernameFromSSO(
             sso, 'foo', 'private-name', dry_run=dry_run)
         self.assertEqual(400, response.status)
         self.assertEqual(
-            'name: The name &#x27;private-name&#x27; has been blocked by the '
-            'Launchpad administrators. Contact Launchpad Support if you want '
-            'to use this name.',
+            b'name: The name &#x27;private-name&#x27; has been blocked by the '
+            b'Launchpad administrators. Contact Launchpad Support if you want '
+            b'to use this name.',
             response.body)
 
         response = self.setUsernameFromSSO(
             sso, taken_openid, 'bar', dry_run=dry_run)
         self.assertEqual(400, response.status)
         self.assertEqual(
-            'An account for that OpenID identifier already exists.',
+            b'An account for that OpenID identifier already exists.',
             response.body)
 
     def test_setUsernameFromSSO_rejects_bad_input_in_dry_run(self):
@@ -562,7 +562,7 @@ class PersonSetWebServiceTests(TestCaseWithFactory):
         response = self.addSSHKeyForPerson('doesnotexist', 'sdf')
         self.assertEqual(400, response.status)
         self.assertEqual(
-            "No account found for openid identifier 'doesnotexist'",
+            b"No account found for openid identifier 'doesnotexist'",
             response.body)
 
     def test_addSSHKeyFromSSO_rejects_bad_key_data(self):
@@ -572,7 +572,7 @@ class PersonSetWebServiceTests(TestCaseWithFactory):
         response = self.addSSHKeyForPerson(openid_id, 'bad_data')
         self.assertEqual(400, response.status)
         self.assertEqual(
-            "Invalid SSH key data: 'bad_data'",
+            b"Invalid SSH key data: 'bad_data'",
             response.body)
 
     def test_addSSHKeyFromSSO_rejects_bad_key_type(self):
@@ -582,7 +582,7 @@ class PersonSetWebServiceTests(TestCaseWithFactory):
         response = self.addSSHKeyForPerson(openid_id, 'foo keydata comment')
         self.assertEqual(400, response.status)
         self.assertEqual(
-            "Invalid SSH key type: 'foo'",
+            b"Invalid SSH key type: 'foo'",
             response.body)
 
     def test_addSSHKeyFromSSO_rejects_bad_key_type_dry_run(self):
@@ -593,7 +593,7 @@ class PersonSetWebServiceTests(TestCaseWithFactory):
             openid_id, 'foo keydata comment', True)
         self.assertEqual(400, response.status)
         self.assertEqual(
-            "Invalid SSH key type: 'foo'",
+            b"Invalid SSH key type: 'foo'",
             response.body)
 
     def test_addSSHKeyFromSSO_works(self):
@@ -648,7 +648,7 @@ class PersonSetWebServiceTests(TestCaseWithFactory):
             'doesnotexist', 'sdf', dry_run)
         self.assertEqual(400, response.status)
         self.assertEqual(
-            "No account found for openid identifier 'doesnotexist'",
+            b"No account found for openid identifier 'doesnotexist'",
             response.body)
 
     def test_deleteSSHKeyFromSSO_nonexistant_dry_run(self):
@@ -663,7 +663,7 @@ class PersonSetWebServiceTests(TestCaseWithFactory):
             openid_id, 'bad_data', dry_run)
         self.assertEqual(400, response.status)
         self.assertEqual(
-            "Invalid SSH key data: 'bad_data'",
+            b"Invalid SSH key data: 'bad_data'",
             response.body)
 
     def test_deleteSSHKeyFromSSO_rejects_bad_key_data_dry_run(self):
@@ -678,7 +678,7 @@ class PersonSetWebServiceTests(TestCaseWithFactory):
             openid_id, 'foo keydata comment', dry_run)
         self.assertEqual(400, response.status)
         self.assertEqual(
-            "Invalid SSH key type: 'foo'",
+            b"Invalid SSH key type: 'foo'",
             response.body)
 
     def test_deleteSSHKeyFromSSO_rejects_bad_key_type_dry_run(self):
diff --git a/lib/lp/registry/tests/test_product_webservice.py b/lib/lp/registry/tests/test_product_webservice.py
index 997d36b..6e38554 100644
--- a/lib/lp/registry/tests/test_product_webservice.py
+++ b/lib/lp/registry/tests/test_product_webservice.py
@@ -80,8 +80,8 @@ class TestProduct(TestCaseWithFactory):
             webservice, product, branch_sharing_policy='Proprietary')
         self.assertThat(response, MatchesStructure.byEquality(
                 status=403,
-                body=('A current commercial subscription is required to use '
-                      'proprietary branches.')))
+                body=(b'A current commercial subscription is required to use '
+                      b'proprietary branches.')))
         with person_logged_in(owner):
             self.assertEqual(
                 BranchSharingPolicy.PUBLIC, product.branch_sharing_policy)
@@ -111,8 +111,8 @@ class TestProduct(TestCaseWithFactory):
             webservice, product, bug_sharing_policy='Proprietary')
         self.assertThat(response, MatchesStructure.byEquality(
                 status=403,
-                body=('A current commercial subscription is required to use '
-                      'proprietary bugs.')))
+                body=(b'A current commercial subscription is required to use '
+                      b'proprietary bugs.')))
         with person_logged_in(owner):
             self.assertEqual(
                 BugSharingPolicy.PUBLIC, product.bug_sharing_policy)
diff --git a/lib/lp/services/webhooks/tests/test_webservice.py b/lib/lp/services/webhooks/tests/test_webservice.py
index ba8bb91..4c90b0e 100644
--- a/lib/lp/services/webhooks/tests/test_webservice.py
+++ b/lib/lp/services/webhooks/tests/test_webservice.py
@@ -119,13 +119,15 @@ class TestWebhook(TestCaseWithFactory):
         self.assertThat(response,
             MatchesStructure.byEquality(
                 status=400,
-                body="event_types: u'hg:push:0.1' isn't a valid token"))
+                body=(
+                    "event_types: %r isn't a valid token" %
+                    u'hg:push:0.1').encode('ASCII')))
 
     def test_anon_forbidden(self):
         response = LaunchpadWebServiceCaller().get(
             self.webhook_url, api_version='devel')
         self.assertEqual(401, response.status)
-        self.assertIn('launchpad.View', response.body)
+        self.assertIn(b'launchpad.View', response.body)
 
     def test_deliveries(self):
         representation = self.webservice.get(
@@ -294,7 +296,7 @@ class TestWebhookTargetBase:
         response = webservice.get(
             self.target_url + '/webhooks', api_version='devel')
         self.assertEqual(401, response.status)
-        self.assertIn('launchpad.Edit', response.body)
+        self.assertIn(b'launchpad.Edit', response.body)
 
     def test_webhooks_query_count(self):
         def get_webhooks():
@@ -351,7 +353,7 @@ class TestWebhookTargetBase:
             delivery_url='http://example.com/ep',
             event_types=[self.event_type], api_version='devel')
         self.assertEqual(401, response.status)
-        self.assertIn('launchpad.Edit', response.body)
+        self.assertIn(b'launchpad.Edit', response.body)
 
     def test_newWebhook_feature_flag_guard(self):
         response = self.webservice.named_post(
@@ -360,7 +362,7 @@ class TestWebhookTargetBase:
             event_types=[self.event_type], api_version='devel')
         self.assertEqual(401, response.status)
         self.assertEqual(
-            'This webhook feature is not available yet.', response.body)
+            b'This webhook feature is not available yet.', response.body)
 
 
 class TestWebhookTargetGitRepository(
diff --git a/lib/lp/services/webservice/stories/xx-service.txt b/lib/lp/services/webservice/stories/xx-service.txt
index 92e31f5..63b40a9 100644
--- a/lib/lp/services/webservice/stories/xx-service.txt
+++ b/lib/lp/services/webservice/stories/xx-service.txt
@@ -56,7 +56,7 @@ consumer keys.
     >>> response = caller.get(root)
     >>> response.status
     401
-    >>> print(response.body)
+    >>> print(six.ensure_text(response.body))
     Unknown consumer (new-consumer).
 
 But with anonymous access there is no registration step. The first
@@ -81,7 +81,7 @@ Anonymous requests can't access certain data.
     >>> response = anon_webservice.get(body['me_link'])
     >>> response.status
     401
-    >>> print(response.body)
+    >>> print(six.ensure_text(response.body))
     You need to be logged in to view this URL.
 
 Anonymous requests can't change the dataset.
@@ -92,7 +92,7 @@ Anonymous requests can't change the dataset.
     ...     'application/json', data)
     >>> response.status
     401
-    >>> print(response.body)
+    >>> print(six.ensure_text(response.body))
     (<Person at...>, 'display_name', 'launchpad.Edit')
 
 A completely unsigned web service request is treated as an anonymous
diff --git a/lib/lp/snappy/tests/test_snap.py b/lib/lp/snappy/tests/test_snap.py
index b3b6bc5..e6da91f 100644
--- a/lib/lp/snappy/tests/test_snap.py
+++ b/lib/lp/snappy/tests/test_snap.py
@@ -2595,7 +2595,7 @@ class TestSnapWebservice(TestCaseWithFactory):
             name="mir", branch=branch_url)
         self.assertEqual(400, response.status)
         self.assertEqual(
-            "There is already a snap package with the same name and owner.",
+            b"There is already a snap package with the same name and owner.",
             response.body)
 
     def test_not_owner(self):
@@ -2617,14 +2617,14 @@ class TestSnapWebservice(TestCaseWithFactory):
             distro_series=distroseries_url, name="dummy", branch=branch_url)
         self.assertEqual(401, response.status)
         self.assertEqual(
-            "Test Person cannot create snap packages owned by Other Person.",
+            b"Test Person cannot create snap packages owned by Other Person.",
             response.body)
         response = self.webservice.named_post(
             "/+snaps", "new", owner=other_team_url,
             distro_series=distroseries_url, name="dummy", branch=branch_url)
         self.assertEqual(401, response.status)
         self.assertEqual(
-            "Test Person is not a member of Other Team.", response.body)
+            b"Test Person is not a member of Other Team.", response.body)
 
     def test_cannot_make_snap_with_private_components_public(self):
         # If a Snap has private components, then trying to make it public
@@ -2646,7 +2646,7 @@ class TestSnapWebservice(TestCaseWithFactory):
             snap_url, "application/json", json.dumps({"private": False}))
         self.assertEqual(400, response.status)
         self.assertEqual(
-            "Snap contains private information and cannot be public.",
+            b"Snap contains private information and cannot be public.",
             response.body)
 
     def test_cannot_set_private_components_of_public_snap(self):
@@ -2681,25 +2681,25 @@ class TestSnapWebservice(TestCaseWithFactory):
             json.dumps({"owner_link": private_team_url}))
         self.assertEqual(400, response.status)
         self.assertEqual(
-            "A public snap cannot have a private owner.", response.body)
+            b"A public snap cannot have a private owner.", response.body)
         response = private_webservice.patch(
             bzr_snap_url, "application/json",
             json.dumps({"branch_link": private_branch_url}))
         self.assertEqual(400, response.status)
         self.assertEqual(
-            "A public snap cannot have a private branch.", response.body)
+            b"A public snap cannot have a private branch.", response.body)
         response = private_webservice.patch(
             git_snap_url, "application/json",
             json.dumps({"owner_link": private_team_url}))
         self.assertEqual(400, response.status)
         self.assertEqual(
-            "A public snap cannot have a private owner.", response.body)
+            b"A public snap cannot have a private owner.", response.body)
         response = private_webservice.patch(
             git_snap_url, "application/json",
             json.dumps({"git_ref_link": private_ref_url}))
         self.assertEqual(400, response.status)
         self.assertEqual(
-            "A public snap cannot have a private repository.", response.body)
+            b"A public snap cannot have a private repository.", response.body)
 
     def test_cannot_set_git_path_for_bzr(self):
         # Setting git_path on a Bazaar-based Snap fails.
@@ -2767,7 +2767,7 @@ class TestSnapWebservice(TestCaseWithFactory):
             "/+snaps", "getByName", owner=owner_url, name="nonexistent")
         self.assertEqual(404, response.status)
         self.assertEqual(
-            "No such snap package with this owner: 'nonexistent'.",
+            b"No such snap package with this owner: 'nonexistent'.",
             response.body)
 
     def test_findByOwner(self):
@@ -3500,7 +3500,7 @@ class TestSnapWebservice(TestCaseWithFactory):
             distro_arch_series=distroarchseries_url, pocket="Updates")
         self.assertEqual(400, response.status)
         self.assertEqual(
-            "An identical build of this snap package is already pending.",
+            b"An identical build of this snap package is already pending.",
             response.body)
 
     def test_requestBuild_not_owner(self):
@@ -3525,8 +3525,8 @@ class TestSnapWebservice(TestCaseWithFactory):
             distro_arch_series=distroarchseries_url, pocket="Updates")
         self.assertEqual(401, response.status)
         self.assertEqual(
-            "Test Person cannot create snap package builds owned by Other "
-            "Team.", response.body)
+            b"Test Person cannot create snap package builds owned by Other "
+            b"Team.", response.body)
 
     def test_requestBuild_archive_disabled(self):
         # Build requests against a disabled archive are rejected.
@@ -3546,7 +3546,7 @@ class TestSnapWebservice(TestCaseWithFactory):
             snap["self_link"], "requestBuild", archive=archive_url,
             distro_arch_series=distroarchseries_url, pocket="Updates")
         self.assertEqual(403, response.status)
-        self.assertEqual("Disabled Archive is disabled.", response.body)
+        self.assertEqual(b"Disabled Archive is disabled.", response.body)
 
     def test_requestBuild_archive_private_owners_match(self):
         # Build requests against a private archive are allowed if the Snap
@@ -3587,8 +3587,8 @@ class TestSnapWebservice(TestCaseWithFactory):
             distro_arch_series=distroarchseries_url, pocket="Updates")
         self.assertEqual(403, response.status)
         self.assertEqual(
-            "Snap package builds against private archives are only allowed "
-            "if the snap package owner and the archive owner are equal.",
+            b"Snap package builds against private archives are only allowed "
+            b"if the snap package owner and the archive owner are equal.",
             response.body)
 
     def test_requestBuilds(self):
@@ -3732,8 +3732,8 @@ class TestSnapWebservice(TestCaseWithFactory):
             pocket="Updates")
         self.assertEqual(401, response.status)
         self.assertEqual(
-            "Test Person cannot create snap package builds owned by Other "
-            "Team.", response.body)
+            b"Test Person cannot create snap package builds owned by Other "
+            b"Team.", response.body)
 
     def test_requestAutoBuilds(self):
         # requestAutoBuilds can be performed over the webservice.
@@ -3764,8 +3764,8 @@ class TestSnapWebservice(TestCaseWithFactory):
             snap["self_link"], "requestAutoBuilds")
         self.assertEqual(400, response.status)
         self.assertEqual(
-            "This snap package cannot have automatic builds created for it "
-            "because auto_build_archive is not set.",
+            b"This snap package cannot have automatic builds created for it "
+            b"because auto_build_archive is not set.",
             response.body)
 
     def test_requestAutoBuilds_requires_auto_build_pocket(self):
@@ -3775,8 +3775,8 @@ class TestSnapWebservice(TestCaseWithFactory):
             snap["self_link"], "requestAutoBuilds")
         self.assertEqual(400, response.status)
         self.assertEqual(
-            "This snap package cannot have automatic builds created for it "
-            "because auto_build_pocket is not set.",
+            b"This snap package cannot have automatic builds created for it "
+            b"because auto_build_pocket is not set.",
             response.body)
 
     def test_requestAutoBuilds_requires_all_requests_to_succeed(self):
@@ -3797,7 +3797,8 @@ class TestSnapWebservice(TestCaseWithFactory):
             snap["self_link"], "requestAutoBuilds")
         self.assertEqual(403, response.status)
         self.assertEqual(
-            "%s is disabled." % archive.displayname, response.body)
+            ("%s is disabled." % archive.displayname).encode("UTF-8"),
+            response.body)
         response = self.webservice.get(snap["builds_collection_link"])
         self.assertEqual([], response.jsonBody()["entries"])
 
diff --git a/lib/lp/snappy/tests/test_snapbase.py b/lib/lp/snappy/tests/test_snapbase.py
index 77dc99c..f45feda 100644
--- a/lib/lp/snappy/tests/test_snapbase.py
+++ b/lib/lp/snappy/tests/test_snapbase.py
@@ -178,7 +178,7 @@ class TestSnapBaseWebservice(TestCaseWithFactory):
             build_channels={"snapcraft": "stable"})
         self.assertEqual(400, response.status)
         self.assertEqual(
-            "name: dummy is already in use by another base.", response.body)
+            b"name: dummy is already in use by another base.", response.body)
 
     def test_getByName(self):
         # lp.snap_bases.getByName returns a matching SnapBase.
@@ -203,7 +203,7 @@ class TestSnapBaseWebservice(TestCaseWithFactory):
         response = webservice.named_get(
             "/+snap-bases", "getByName", name="nonexistent")
         self.assertEqual(404, response.status)
-        self.assertEqual("No such base: 'nonexistent'.", response.body)
+        self.assertEqual(b"No such base: 'nonexistent'.", response.body)
 
     def test_getDefault(self):
         # lp.snap_bases.getDefault returns the default SnapBase, if any.
diff --git a/lib/lp/snappy/tests/test_snappyseries.py b/lib/lp/snappy/tests/test_snappyseries.py
index 7ae2272..173877a 100644
--- a/lib/lp/snappy/tests/test_snappyseries.py
+++ b/lib/lp/snappy/tests/test_snappyseries.py
@@ -188,7 +188,7 @@ class TestSnappySeriesWebservice(TestCaseWithFactory):
             name="dummy", display_name="Dummy", status="Experimental")
         self.assertEqual(400, response.status)
         self.assertEqual(
-            "name: dummy is already in use by another series.", response.body)
+            b"name: dummy is already in use by another series.", response.body)
 
     def test_getByName(self):
         # lp.snappy_serieses.getByName returns a matching SnappySeries.
@@ -215,7 +215,7 @@ class TestSnappySeriesWebservice(TestCaseWithFactory):
             "/+snappy-series", "getByName", name="nonexistent")
         self.assertEqual(404, response.status)
         self.assertEqual(
-            "No such snappy series: 'nonexistent'.", response.body)
+            b"No such snappy series: 'nonexistent'.", response.body)
 
     def test_collection(self):
         # lp.snappy_serieses is a collection of all SnappySeries.
diff --git a/lib/lp/soyuz/browser/tests/test_archive_webservice.py b/lib/lp/soyuz/browser/tests/test_archive_webservice.py
index 1ce3759..68e7d64 100644
--- a/lib/lp/soyuz/browser/tests/test_archive_webservice.py
+++ b/lib/lp/soyuz/browser/tests/test_archive_webservice.py
@@ -124,7 +124,7 @@ class TestArchiveWebservice(TestCaseWithFactory):
         self.assertThat(
             ws.delete(ppa_url),
             MatchesStructure.byEquality(
-                status=400, body="Archive already deleted."))
+                status=400, body=b"Archive already deleted."))
 
     def test_delete_is_restricted(self):
         with admin_logged_in():
diff --git a/lib/lp/soyuz/tests/test_binarypackagebuild.py b/lib/lp/soyuz/tests/test_binarypackagebuild.py
index 21b73d7..0c7b95a 100644
--- a/lib/lp/soyuz/tests/test_binarypackagebuild.py
+++ b/lib/lp/soyuz/tests/test_binarypackagebuild.py
@@ -628,7 +628,7 @@ class TestBinaryPackageBuildWebservice(TestCaseWithFactory):
             entry["self_link"], "application/json",
             dumps({"external_dependencies": "random"}))
         self.assertEqual(400, response.status)
-        self.assertIn("Invalid external dependencies", response.body)
+        self.assertIn(b"Invalid external dependencies", response.body)
 
     def test_external_dependencies_ppa_owner_valid(self):
         # PPA admins can look and touch.
diff --git a/lib/lp/soyuz/tests/test_livefs.py b/lib/lp/soyuz/tests/test_livefs.py
index 70e276d..4ab23cf 100644
--- a/lib/lp/soyuz/tests/test_livefs.py
+++ b/lib/lp/soyuz/tests/test_livefs.py
@@ -620,8 +620,8 @@ class TestLiveFSWebservice(TestCaseWithFactory):
             metadata={})
         self.assertEqual(400, response.status)
         self.assertEqual(
-            "There is already a live filesystem with the same name, owner, "
-            "and distroseries.", response.body)
+            b"There is already a live filesystem with the same name, owner, "
+            b"and distroseries.", response.body)
 
     def test_not_owner(self):
         # If the registrant is not the owner or a member of the owner team,
@@ -640,14 +640,14 @@ class TestLiveFSWebservice(TestCaseWithFactory):
             distro_series=distroseries_url, name="dummy", metadata={})
         self.assertEqual(401, response.status)
         self.assertEqual(
-            "Test Person cannot create live filesystems owned by Other "
-            "Person.", response.body)
+            b"Test Person cannot create live filesystems owned by Other "
+            b"Person.", response.body)
         response = self.webservice.named_post(
             "/livefses", "new", owner=other_team_url,
             distro_series=distroseries_url, name="dummy", metadata={})
         self.assertEqual(401, response.status)
         self.assertEqual(
-            "Test Person is not a member of Other Team.", response.body)
+            b"Test Person is not a member of Other Team.", response.body)
 
     def test_getByName(self):
         # lp.livefses.getByName returns a matching LiveFS.
@@ -670,8 +670,8 @@ class TestLiveFSWebservice(TestCaseWithFactory):
             distro_series=distroseries_url, name="nonexistent")
         self.assertEqual(404, response.status)
         self.assertEqual(
-            "No such live filesystem with this owner/distroseries: "
-            "'nonexistent'.", response.body)
+            b"No such live filesystem with this owner/distroseries: "
+            b"'nonexistent'.", response.body)
 
     def test_requestBuild(self):
         # Build requests can be performed and end up in livefs.builds and
@@ -712,8 +712,8 @@ class TestLiveFSWebservice(TestCaseWithFactory):
             distro_arch_series=distroarchseries_url, pocket="Release")
         self.assertEqual(400, response.status)
         self.assertEqual(
-            "An identical build of this live filesystem image is already "
-            "pending.", response.body)
+            b"An identical build of this live filesystem image is already "
+            b"pending.", response.body)
 
     def test_requestBuild_not_owner(self):
         # If the requester is not the owner or a member of the owner team,
@@ -736,8 +736,8 @@ class TestLiveFSWebservice(TestCaseWithFactory):
             distro_arch_series=distroarchseries_url, pocket="Release")
         self.assertEqual(401, response.status)
         self.assertEqual(
-            "Test Person cannot create live filesystem builds owned by Other "
-            "Team.", response.body)
+            b"Test Person cannot create live filesystem builds owned by Other "
+            b"Team.", response.body)
 
     def test_requestBuild_archive_disabled(self):
         # Build requests against a disabled archive are rejected.
@@ -756,7 +756,7 @@ class TestLiveFSWebservice(TestCaseWithFactory):
             livefs["self_link"], "requestBuild", archive=archive_url,
             distro_arch_series=distroarchseries_url, pocket="Release")
         self.assertEqual(403, response.status)
-        self.assertEqual("Disabled Archive is disabled.", response.body)
+        self.assertEqual(b"Disabled Archive is disabled.", response.body)
 
     def test_requestBuild_archive_private_owners_match(self):
         # Build requests against a private archive are allowed if the LiveFS
@@ -798,8 +798,9 @@ class TestLiveFSWebservice(TestCaseWithFactory):
             distro_arch_series=distroarchseries_url, pocket="Release")
         self.assertEqual(403, response.status)
         self.assertEqual(
-            "Live filesystem builds against private archives are only allowed "
-            "if the live filesystem owner and the archive owner are equal.",
+            b"Live filesystem builds against private archives are only "
+            b"allowed if the live filesystem owner and the archive owner are "
+            b"equal.",
             response.body)
 
     def test_getBuilds(self):