← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad-buildd:py3-snap-proxy-tests into launchpad-buildd:master

 

Colin Watson has proposed merging ~cjwatson/launchpad-buildd:py3-snap-proxy-tests into launchpad-buildd:master.

Commit message:
Fix snap proxy testing for Python 3

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad-buildd/+git/launchpad-buildd/+merge/383444

Various details of what Twisted expects in terms of bytes vs. text weren't quite right.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad-buildd:py3-snap-proxy-tests into launchpad-buildd:master.
diff --git a/debian/changelog b/debian/changelog
index 1995088..c6b5734 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -11,6 +11,7 @@ launchpad-buildd (190) UNRELEASED; urgency=medium
   * Treat build logs as binary files.
   * Treat build output files as binary files.
   * Treat intltool-related files as binary files.
+  * Fix snap proxy testing for Python 3.
 
  -- Colin Watson <cjwatson@xxxxxxxxxx>  Tue, 28 Apr 2020 10:19:27 +0100
 
diff --git a/lpbuildd/tests/test_snap.py b/lpbuildd/tests/test_snap.py
index e747048..111698a 100644
--- a/lpbuildd/tests/test_snap.py
+++ b/lpbuildd/tests/test_snap.py
@@ -388,7 +388,7 @@ class TestSnapBuildManagerIteration(TestCase):
 
     def getListenerURL(self, listener):
         port = listener.getHost().port
-        return b"http://localhost:%d/"; % port
+        return "http://localhost:%d/"; % port
 
     def startFakeRemoteEndpoint(self):
         remote_endpoint = resource.Resource()
@@ -421,8 +421,10 @@ class TestSnapBuildManagerIteration(TestCase):
         out, err, code = yield utils.getProcessOutputAndValue(
             command[0], command[1:], env=env, path=".")
         if code != 0:
-            self.addDetail("stdout", text_content(out))
-            self.addDetail("stderr", text_content(err))
+            self.addDetail(
+                "stdout", text_content(out.decode("UTF-8", "replace")))
+            self.addDetail(
+                "stderr", text_content(err.decode("UTF-8", "replace")))
             self.assertEqual(0, code)
         defer.returnValue(out)
 
@@ -434,13 +436,13 @@ class TestSnapBuildManagerIteration(TestCase):
         proxy_listener = self.startLocalProxy(
             self.getListenerURL(remote_proxy_listener))
         out = yield self.assertCommandSuccess(
-            [b"curl", remote_endpoint_url + b"a"],
-            extra_env={b"http_proxy": self.getListenerURL(proxy_listener)})
-        self.assertEqual("a" * 1024, out)
+            [b"curl", remote_endpoint_url.encode("UTF-8") + b"a"],
+            extra_env={"http_proxy": self.getListenerURL(proxy_listener)})
+        self.assertEqual(b"a" * 1024, out)
         out = yield self.assertCommandSuccess(
-            [b"curl", remote_endpoint_url + b"b"],
-            extra_env={b"http_proxy": self.getListenerURL(proxy_listener)})
-        self.assertEqual("b" * 65536, out)
+            [b"curl", remote_endpoint_url.encode("UTF-8") + b"b"],
+            extra_env={"http_proxy": self.getListenerURL(proxy_listener)})
+        self.assertEqual(b"b" * 65536, out)
 
     # XXX cjwatson 2017-04-13: We should really test the HTTPS case as well,
     # but it's hard to see how to test that in a way that's independent of

Follow ups