launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #24671
[Merge] ~cjwatson/launchpad-buildd:py3-backends into launchpad-buildd:master
Colin Watson has proposed merging ~cjwatson/launchpad-buildd:py3-backends into launchpad-buildd:master.
Commit message:
Fix bytes/text handling in backends and their tests
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad-buildd/+git/launchpad-buildd/+merge/383363
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad-buildd:py3-backends into launchpad-buildd:master.
diff --git a/debian/changelog b/debian/changelog
index 1995088..f4bf936 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 bytes/text handling in backends and their tests.
-- Colin Watson <cjwatson@xxxxxxxxxx> Tue, 28 Apr 2020 10:19:27 +0100
diff --git a/lpbuildd/target/backend.py b/lpbuildd/target/backend.py
index 180bbcc..8356542 100644
--- a/lpbuildd/target/backend.py
+++ b/lpbuildd/target/backend.py
@@ -155,7 +155,7 @@ class Backend:
with open("/dev/null", "w") as devnull:
output = self.run(
["apt-cache", "show", package],
- get_output=True, stderr=devnull)
+ get_output=True, stderr=devnull, universal_newlines=True)
return ("Package: %s" % package) in output.splitlines()
except subprocess.CalledProcessError:
return False
diff --git a/lpbuildd/target/tests/test_chroot.py b/lpbuildd/target/tests/test_chroot.py
index 0361e25..861a893 100644
--- a/lpbuildd/target/tests/test_chroot.py
+++ b/lpbuildd/target/tests/test_chroot.py
@@ -105,7 +105,7 @@ class TestChroot(TestCase):
processes_fixture.add(
lambda _: {"stdout": io.BytesIO(b"hello\n")}, name="sudo")
self.assertEqual(
- "hello\n",
+ b"hello\n",
Chroot("1", "xenial", "amd64").run(
["echo", "hello"], get_output=True))
@@ -289,9 +289,9 @@ class TestChroot(TestCase):
self.useFixture(EnvironmentVariable("HOME", "/expected/home"))
processes_fixture = self.useFixture(FakeProcesses())
test_proc_infos = iter([
- {"stdout": io.BytesIO(b"Package: snapd\n")},
+ {"stdout": io.StringIO(u"Package: snapd\n")},
{"returncode": 100},
- {"stderr": io.BytesIO(b"N: No packages found\n")},
+ {"stderr": io.StringIO(u"N: No packages found\n")},
])
processes_fixture.add(lambda _: next(test_proc_infos), name="sudo")
self.assertTrue(
diff --git a/lpbuildd/target/tests/test_lxd.py b/lpbuildd/target/tests/test_lxd.py
index 7377de1..77e7f77 100644
--- a/lpbuildd/target/tests/test_lxd.py
+++ b/lpbuildd/target/tests/test_lxd.py
@@ -215,7 +215,7 @@ class TestLXD(TestCase):
with io.BytesIO(client.images.create.call_args[0][0]) as f:
with tarfile.open(fileobj=f) as tar:
with closing(tar.extractfile("rootfs/bin/hello")) as hello:
- self.assertEqual("hello\n", hello.read())
+ self.assertEqual(b"hello\n", hello.read())
image.add_alias.assert_called_once_with(
"lp-xenial-amd64", "lp-xenial-amd64")
@@ -245,7 +245,7 @@ class TestLXD(TestCase):
with io.BytesIO(client.images.create.call_args[0][0]) as f:
with tarfile.open(fileobj=f) as tar:
with closing(tar.extractfile("rootfs/bin/hello")) as hello:
- self.assertEqual("hello\n", hello.read())
+ self.assertEqual(b"hello\n", hello.read())
image.add_alias.assert_called_once_with(
"lp-xenial-amd64", "lp-xenial-amd64")
@@ -271,7 +271,7 @@ class TestLXD(TestCase):
with io.BytesIO(client.images.create.call_args[0][0]) as f:
with tarfile.open(fileobj=f) as tar:
with closing(tar.extractfile("rootfs/bin/hello")) as hello:
- self.assertEqual("hello\n", hello.read())
+ self.assertEqual(b"hello\n", hello.read())
image.add_alias.assert_called_once_with(
"lp-xenial-amd64", "lp-xenial-amd64")
@@ -573,14 +573,14 @@ class TestLXD(TestCase):
files_api = container.api.files
files_api._api_endpoint = "/1.0/containers/lp-trusty-amd64/files"
files_api.session.get.side_effect = FakeSessionGet({
- "/etc/init/mounted-dev.conf": dedent("""\
+ "/etc/init/mounted-dev.conf": [dedent("""\
start on mounted MOUNTPOINT=/dev
script
[ -e /dev/shm ] || ln -s /run/shm /dev/shm
/sbin/MAKEDEV std fd ppp tun
end script
task
- """)})
+ """).encode("UTF-8")]})
processes_fixture = self.useFixture(FakeProcesses())
processes_fixture.add(lambda _: {}, name="sudo")
processes_fixture.add(lambda _: {}, name="lxc")
@@ -618,7 +618,7 @@ class TestLXD(TestCase):
processes_fixture.add(
lambda _: {"stdout": io.BytesIO(b"hello\n")}, name="lxc")
self.assertEqual(
- "hello\n",
+ b"hello\n",
LXD("1", "xenial", "amd64").run(
["echo", "hello"], get_output=True))
@@ -827,9 +827,9 @@ class TestLXD(TestCase):
def test_is_package_available(self):
processes_fixture = self.useFixture(FakeProcesses())
test_proc_infos = iter([
- {"stdout": io.BytesIO(b"Package: snapd\n")},
+ {"stdout": io.StringIO(u"Package: snapd\n")},
{"returncode": 100},
- {"stderr": io.BytesIO(b"N: No packages found\n")},
+ {"stderr": io.StringIO(u"N: No packages found\n")},
])
processes_fixture.add(lambda _: next(test_proc_infos), name="lxc")
self.assertTrue(