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.
This commit is contained in:
Dimitri John Ledkov 2014-12-18 23:18:00 +00:00
parent 5da114b070
commit 866adfd768
2 changed files with 7 additions and 5 deletions

View File

@ -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',

View File

@ -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):