From 866adfd768e7751a96d9853c505c7fb8462f7d14 Mon Sep 17 00:00:00 2001 From: Dimitri John Ledkov <dimitri.j.ledkov@intel.com> Date: Thu, 18 Dec 2014 23:18:00 +0000 Subject: [PATCH] Actually, now that more things expect streaming bytes over the wire the mirror tests don't stall anymore. Also use a codec.reader to slurp up unicode bytes for json.load. --- ubuntutools/archive.py | 8 ++++++-- ubuntutools/test/test_archive.py | 4 +--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/ubuntutools/archive.py b/ubuntutools/archive.py index 15626d9..46d4c51 100644 --- a/ubuntutools/archive.py +++ b/ubuntutools/archive.py @@ -48,6 +48,7 @@ if sys.version_info[0] >= 3: from debian.changelog import Changelog, Version import debian.deb822 import debian.debian_support +import codecs import httplib2 from ubuntutools.config import UDTConfig @@ -508,10 +509,13 @@ class DebianSourcePackage(SourcePackage): "python-simplejson") try: - srcfiles = json.load(self.url_opener.open( + data = self.url_opener.open( 'http://snapshot.debian.org' '/mr/package/%s/%s/srcfiles?fileinfo=1' - % (self.source, self.version.full_version))) + % (self.source, self.version.full_version)) + reader = codecs.getreader('utf-8') + srcfiles = json.load(reader(data)) + except HTTPError: Logger.error('Version %s of %s not found on ' 'snapshot.debian.org', diff --git a/ubuntutools/test/test_archive.py b/ubuntutools/test/test_archive.py index 2682a5b..0593f40 100644 --- a/ubuntutools/test/test_archive.py +++ b/ubuntutools/test/test_archive.py @@ -226,7 +226,6 @@ class LocalSourcePackageTestCase(unittest.TestCase): pkg.quiet = True pkg.pull() - @unittest.skipIf(sys.version_info[0] >=3, "Stalls on PY3") def test_mirrors(self): master = UDTConfig.defaults['UBUNTU_MIRROR'] mirror = 'http://mirror' @@ -256,7 +255,6 @@ class LocalSourcePackageTestCase(unittest.TestCase): class DebianLocalSourcePackageTestCase(LocalSourcePackageTestCase): SourcePackage = ubuntutools.archive.DebianSourcePackage - @unittest.skipIf(sys.version_info[0] >=3, "Stalls on PY3") def test_mirrors(self): debian_master = UDTConfig.defaults['DEBIAN_MIRROR'] debsec_master = UDTConfig.defaults['DEBSEC_MIRROR'] @@ -271,7 +269,7 @@ class DebianLocalSourcePackageTestCase(LocalSourcePackageTestCase): self.urlopen_404, self.urlopen_404, lambda x: BytesIO( - '{"fileinfo": {"hashabc": [{"name": "example_1.0.orig.tar.gz"}]}}'), + b'{"fileinfo": {"hashabc": [{"name": "example_1.0.orig.tar.gz"}]}}'), self.urlopen_file('example_1.0.orig.tar.gz'), self.urlopen_proxy] def _callable_iter(*args, **kwargs):