Merge "Modify zip usage for python3 where necessary."

This commit is contained in:
Jenkins 2015-07-28 12:52:52 +00:00 committed by Gerrit Code Review
commit 6511100a56
3 changed files with 14 additions and 5 deletions

View File

@ -185,7 +185,11 @@ class ContainerController(BaseStorageServer):
return HTTPBadRequest(req=req)
if account_partition:
updates = zip(account_hosts, account_devices)
# zip is lazy on py3, but we need a list, so force evaluation.
# On py2 it's an extra list copy, but the list is so small
# (one element per replica in account ring, usually 3) that it
# doesn't matter.
updates = list(zip(account_hosts, account_devices))
else:
updates = []

View File

@ -512,7 +512,9 @@ class DiskFileManagerMixin(BaseDiskFileTestMixin):
chosen = dict((f[1], os.path.join(class_under_test._datadir, f[0]))
for f in test if f[1])
expected = tuple(chosen.get(ext) for ext in returned_ext_order)
files = list(zip(*test)[0])
# list(zip(...)) for py3 compatibility (zip is lazy there)
files = list(list(zip(*test))[0])
for _order in ('ordered', 'shuffled', 'shuffled'):
class_under_test = self._get_diskfile(policy, frag_index)
try:
@ -531,7 +533,8 @@ class DiskFileManagerMixin(BaseDiskFileTestMixin):
# check that expected files are left in hashdir after cleanup
for test in scenarios:
class_under_test = self.df_router[policy]
files = list(zip(*test)[0])
# list(zip(...)) for py3 compatibility (zip is lazy there)
files = list(list(zip(*test))[0])
hashdir = os.path.join(self.testdir, str(uuid.uuid4()))
os.mkdir(hashdir)
for fname in files:
@ -557,7 +560,8 @@ class DiskFileManagerMixin(BaseDiskFileTestMixin):
# same scenarios as passed to _test_hash_cleanup_listdir_files
for test in scenarios:
class_under_test = self.df_router[policy]
files = list(zip(*test)[0])
# list(zip(...)) for py3 compatibility (zip is lazy there)
files = list(list(zip(*test))[0])
dev_path = os.path.join(self.testdir, str(uuid.uuid4()))
hashdir = os.path.join(
dev_path, diskfile.get_data_dir(policy),

View File

@ -974,7 +974,8 @@ class TestECObjController(BaseObjectControllerMixin, unittest.TestCase):
self.assertEqual(len(real_body), len(sanity_body))
self.assertEqual(real_body, sanity_body)
node_fragments = zip(*fragment_payloads)
# list(zip(...)) for py3 compatibility (zip is lazy there)
node_fragments = list(zip(*fragment_payloads))
self.assertEqual(len(node_fragments), self.replicas()) # sanity
headers = {'X-Object-Sysmeta-Ec-Content-Length': str(len(real_body))}
responses = [(200, ''.join(node_fragments[i]), headers)