Merge "py3: Replace gen.next() with next(gen)"
This commit is contained in:
commit
cc46ab0b8f
@ -609,7 +609,7 @@ class TestServer(unittest.TestCase):
|
||||
self.assertRaises(StopIteration, iter.next)
|
||||
# test invalid value in pid file
|
||||
server = manager.Server('auth', run_dir=t)
|
||||
pid_file, pid = server.iter_pid_files().next()
|
||||
pid_file, pid = next(server.iter_pid_files())
|
||||
self.assertEqual(None, pid)
|
||||
# test object-server doesn't steal pids from object-replicator
|
||||
server = manager.Server('object', run_dir=t)
|
||||
|
@ -4629,7 +4629,7 @@ class TestGreenAsyncPile(unittest.TestCase):
|
||||
pile.spawn(lambda: i)
|
||||
self.assertEqual(4, pile._pending)
|
||||
for i in range(3, -1, -1):
|
||||
pile.next()
|
||||
next(pile)
|
||||
self.assertEqual(i, pile._pending)
|
||||
# sanity check - the pile is empty
|
||||
self.assertRaises(StopIteration, pile.next)
|
||||
|
@ -502,8 +502,8 @@ class TestAuditor(unittest.TestCase):
|
||||
def test_with_only_tombstone(self):
|
||||
# sanity check that auditor doesn't touch solitary tombstones
|
||||
ts_iter = make_timestamp_iter()
|
||||
self.setup_bad_zero_byte(timestamp=ts_iter.next())
|
||||
self.disk_file.delete(ts_iter.next())
|
||||
self.setup_bad_zero_byte(timestamp=next(ts_iter))
|
||||
self.disk_file.delete(next(ts_iter))
|
||||
files = os.listdir(self.disk_file._datadir)
|
||||
self.assertEqual(1, len(files))
|
||||
self.assertTrue(files[0].endswith('ts'))
|
||||
@ -516,8 +516,8 @@ class TestAuditor(unittest.TestCase):
|
||||
# rsync replication could leave a tombstone and data file in object
|
||||
# dir - verify they are both removed during audit
|
||||
ts_iter = make_timestamp_iter()
|
||||
ts_tomb = ts_iter.next()
|
||||
ts_data = ts_iter.next()
|
||||
ts_tomb = next(ts_iter)
|
||||
ts_data = next(ts_iter)
|
||||
self.setup_bad_zero_byte(timestamp=ts_data)
|
||||
tomb_file_path = os.path.join(self.disk_file._datadir,
|
||||
'%s.ts' % ts_tomb.internal)
|
||||
|
@ -2023,13 +2023,13 @@ class DiskFileMixin(BaseDiskFileTestMixin):
|
||||
def test_get_datafile_metadata(self):
|
||||
ts_iter = make_timestamp_iter()
|
||||
body = '1234567890'
|
||||
ts_data = ts_iter.next()
|
||||
ts_data = next(ts_iter)
|
||||
metadata = {'X-Object-Meta-Test': 'test1',
|
||||
'X-Object-Sysmeta-Test': 'test1'}
|
||||
df = self._create_test_file(body, timestamp=ts_data.internal,
|
||||
metadata=metadata)
|
||||
expected = df.get_metadata()
|
||||
ts_meta = ts_iter.next()
|
||||
ts_meta = next(ts_iter)
|
||||
df.write_metadata({'X-Timestamp': ts_meta.internal,
|
||||
'X-Object-Meta-Test': 'changed',
|
||||
'X-Object-Sysmeta-Test': 'ignored'})
|
||||
@ -2047,7 +2047,7 @@ class DiskFileMixin(BaseDiskFileTestMixin):
|
||||
def test_get_metafile_metadata(self):
|
||||
ts_iter = make_timestamp_iter()
|
||||
body = '1234567890'
|
||||
ts_data = ts_iter.next()
|
||||
ts_data = next(ts_iter)
|
||||
metadata = {'X-Object-Meta-Test': 'test1',
|
||||
'X-Object-Sysmeta-Test': 'test1'}
|
||||
df = self._create_test_file(body, timestamp=ts_data.internal,
|
||||
@ -2055,7 +2055,7 @@ class DiskFileMixin(BaseDiskFileTestMixin):
|
||||
self.assertIsNone(df.get_metafile_metadata())
|
||||
|
||||
# now create a meta file
|
||||
ts_meta = ts_iter.next()
|
||||
ts_meta = next(ts_iter)
|
||||
df.write_metadata({'X-Timestamp': ts_meta.internal,
|
||||
'X-Object-Meta-Test': 'changed'})
|
||||
df.open()
|
||||
|
@ -342,7 +342,7 @@ class TestObjectController(unittest.TestCase):
|
||||
|
||||
def test_POST_conflicts_with_later_POST(self):
|
||||
ts_iter = make_timestamp_iter()
|
||||
t_put = ts_iter.next().internal
|
||||
t_put = next(ts_iter).internal
|
||||
req = Request.blank('/sda1/p/a/c/o',
|
||||
environ={'REQUEST_METHOD': 'PUT'},
|
||||
headers={'X-Timestamp': t_put,
|
||||
@ -351,8 +351,8 @@ class TestObjectController(unittest.TestCase):
|
||||
resp = req.get_response(self.object_controller)
|
||||
self.assertEqual(resp.status_int, 201)
|
||||
|
||||
t_post1 = ts_iter.next().internal
|
||||
t_post2 = ts_iter.next().internal
|
||||
t_post1 = next(ts_iter).internal
|
||||
t_post2 = next(ts_iter).internal
|
||||
req = Request.blank('/sda1/p/a/c/o',
|
||||
environ={'REQUEST_METHOD': 'POST'},
|
||||
headers={'X-Timestamp': t_post2})
|
||||
@ -1120,7 +1120,7 @@ class TestObjectController(unittest.TestCase):
|
||||
|
||||
def test_PUT_succeeds_with_later_POST(self):
|
||||
ts_iter = make_timestamp_iter()
|
||||
t_put = ts_iter.next().internal
|
||||
t_put = next(ts_iter).internal
|
||||
req = Request.blank('/sda1/p/a/c/o',
|
||||
environ={'REQUEST_METHOD': 'PUT'},
|
||||
headers={'X-Timestamp': t_put,
|
||||
@ -1129,8 +1129,8 @@ class TestObjectController(unittest.TestCase):
|
||||
resp = req.get_response(self.object_controller)
|
||||
self.assertEqual(resp.status_int, 201)
|
||||
|
||||
t_put2 = ts_iter.next().internal
|
||||
t_post = ts_iter.next().internal
|
||||
t_put2 = next(ts_iter).internal
|
||||
t_post = next(ts_iter).internal
|
||||
req = Request.blank('/sda1/p/a/c/o',
|
||||
environ={'REQUEST_METHOD': 'POST'},
|
||||
headers={'X-Timestamp': t_post})
|
||||
@ -2470,7 +2470,7 @@ class TestObjectController(unittest.TestCase):
|
||||
|
||||
def test_DELETE_succeeds_with_later_POST(self):
|
||||
ts_iter = make_timestamp_iter()
|
||||
t_put = ts_iter.next().internal
|
||||
t_put = next(ts_iter).internal
|
||||
req = Request.blank('/sda1/p/a/c/o',
|
||||
environ={'REQUEST_METHOD': 'PUT'},
|
||||
headers={'X-Timestamp': t_put,
|
||||
@ -2479,8 +2479,8 @@ class TestObjectController(unittest.TestCase):
|
||||
resp = req.get_response(self.object_controller)
|
||||
self.assertEqual(resp.status_int, 201)
|
||||
|
||||
t_delete = ts_iter.next().internal
|
||||
t_post = ts_iter.next().internal
|
||||
t_delete = next(ts_iter).internal
|
||||
t_post = next(ts_iter).internal
|
||||
req = Request.blank('/sda1/p/a/c/o',
|
||||
environ={'REQUEST_METHOD': 'POST'},
|
||||
headers={'X-Timestamp': t_post})
|
||||
|
@ -2046,8 +2046,8 @@ class TestModuleMethods(unittest.TestCase):
|
||||
def test_decode_missing(self):
|
||||
object_hash = '9d41d8cd98f00b204e9800998ecf0abc'
|
||||
ts_iter = make_timestamp_iter()
|
||||
t_data = ts_iter.next()
|
||||
t_meta = ts_iter.next()
|
||||
t_data = next(ts_iter)
|
||||
t_meta = next(ts_iter)
|
||||
d_meta_data = t_meta.raw - t_data.raw
|
||||
|
||||
# legacy single timestamp string
|
||||
@ -2092,10 +2092,10 @@ class TestModuleMethods(unittest.TestCase):
|
||||
|
||||
def test_encode_wanted(self):
|
||||
ts_iter = make_timestamp_iter()
|
||||
old_t_data = ts_iter.next()
|
||||
t_data = ts_iter.next()
|
||||
old_t_meta = ts_iter.next()
|
||||
t_meta = ts_iter.next()
|
||||
old_t_data = next(ts_iter)
|
||||
t_data = next(ts_iter)
|
||||
old_t_meta = next(ts_iter)
|
||||
t_meta = next(ts_iter)
|
||||
|
||||
remote = {
|
||||
'object_hash': 'theremotehash',
|
||||
|
@ -1189,10 +1189,10 @@ class TestSender(BaseTestSender):
|
||||
device = 'dev'
|
||||
part = '9'
|
||||
object_parts = ('a', 'c', 'o')
|
||||
t1 = ts_iter.next()
|
||||
t1 = next(ts_iter)
|
||||
df = self._make_open_diskfile(
|
||||
device, part, *object_parts, timestamp=t1)
|
||||
t2 = ts_iter.next()
|
||||
t2 = next(ts_iter)
|
||||
metadata = {'X-Timestamp': t2.internal, 'X-Object-Meta-Fruit': 'kiwi'}
|
||||
df.write_metadata(metadata)
|
||||
object_hash = utils.hash_path(*object_parts)
|
||||
@ -1236,10 +1236,10 @@ class TestSender(BaseTestSender):
|
||||
device = 'dev'
|
||||
part = '9'
|
||||
object_parts = ('a', 'c', 'o')
|
||||
t1 = ts_iter.next()
|
||||
t1 = next(ts_iter)
|
||||
df = self._make_open_diskfile(
|
||||
device, part, *object_parts, timestamp=t1)
|
||||
t2 = ts_iter.next()
|
||||
t2 = next(ts_iter)
|
||||
metadata = {'X-Timestamp': t2.internal, 'X-Object-Meta-Fruit': 'kiwi'}
|
||||
df.write_metadata(metadata)
|
||||
object_hash = utils.hash_path(*object_parts)
|
||||
@ -1283,10 +1283,10 @@ class TestSender(BaseTestSender):
|
||||
device = 'dev'
|
||||
part = '9'
|
||||
object_parts = ('a', 'c', 'o')
|
||||
t1 = ts_iter.next()
|
||||
t1 = next(ts_iter)
|
||||
df = self._make_open_diskfile(
|
||||
device, part, *object_parts, timestamp=t1)
|
||||
t2 = ts_iter.next()
|
||||
t2 = next(ts_iter)
|
||||
metadata = {'X-Timestamp': t2.internal, 'X-Object-Meta-Fruit': 'kiwi'}
|
||||
df.write_metadata(metadata)
|
||||
object_hash = utils.hash_path(*object_parts)
|
||||
@ -1529,7 +1529,7 @@ class TestSender(BaseTestSender):
|
||||
|
||||
def test_send_put(self):
|
||||
ts_iter = make_timestamp_iter()
|
||||
t1 = ts_iter.next()
|
||||
t1 = next(ts_iter)
|
||||
body = 'test'
|
||||
extra_metadata = {'Some-Other-Header': 'value'}
|
||||
df = self._make_open_diskfile(body=body, timestamp=t1,
|
||||
@ -1538,7 +1538,7 @@ class TestSender(BaseTestSender):
|
||||
expected['body'] = body
|
||||
expected['chunk_size'] = len(body)
|
||||
# .meta file metadata is not included in expected for data only PUT
|
||||
t2 = ts_iter.next()
|
||||
t2 = next(ts_iter)
|
||||
metadata = {'X-Timestamp': t2.internal, 'X-Object-Meta-Fruit': 'kiwi'}
|
||||
df.write_metadata(metadata)
|
||||
df.open()
|
||||
@ -2200,9 +2200,9 @@ class TestSsyncReplication(TestBaseSsync):
|
||||
expected_subreqs = defaultdict(list)
|
||||
|
||||
# o1 on tx only with meta file
|
||||
t1 = self.ts_iter.next()
|
||||
t1 = next(self.ts_iter)
|
||||
tx_objs['o1'] = self._create_ondisk_files(tx_df_mgr, 'o1', policy, t1)
|
||||
t1_meta = self.ts_iter.next()
|
||||
t1_meta = next(self.ts_iter)
|
||||
metadata = {'X-Timestamp': t1_meta.internal,
|
||||
'X-Object-Meta-Test': 'o1',
|
||||
'X-Object-Sysmeta-Test': 'sys_o1'}
|
||||
@ -2211,9 +2211,9 @@ class TestSsyncReplication(TestBaseSsync):
|
||||
expected_subreqs['POST'].append('o1')
|
||||
|
||||
# o2 on tx with meta, on rx without meta
|
||||
t2 = self.ts_iter.next()
|
||||
t2 = next(self.ts_iter)
|
||||
tx_objs['o2'] = self._create_ondisk_files(tx_df_mgr, 'o2', policy, t2)
|
||||
t2_meta = self.ts_iter.next()
|
||||
t2_meta = next(self.ts_iter)
|
||||
metadata = {'X-Timestamp': t2_meta.internal,
|
||||
'X-Object-Meta-Test': 'o2',
|
||||
'X-Object-Sysmeta-Test': 'sys_o2'}
|
||||
@ -2222,11 +2222,11 @@ class TestSsyncReplication(TestBaseSsync):
|
||||
expected_subreqs['POST'].append('o2')
|
||||
|
||||
# o3 is on tx with meta, rx has newer data but no meta
|
||||
t3a = self.ts_iter.next()
|
||||
t3a = next(self.ts_iter)
|
||||
tx_objs['o3'] = self._create_ondisk_files(tx_df_mgr, 'o3', policy, t3a)
|
||||
t3b = self.ts_iter.next()
|
||||
t3b = next(self.ts_iter)
|
||||
rx_objs['o3'] = self._create_ondisk_files(rx_df_mgr, 'o3', policy, t3b)
|
||||
t3_meta = self.ts_iter.next()
|
||||
t3_meta = next(self.ts_iter)
|
||||
metadata = {'X-Timestamp': t3_meta.internal,
|
||||
'X-Object-Meta-Test': 'o3',
|
||||
'X-Object-Sysmeta-Test': 'sys_o3'}
|
||||
@ -2234,11 +2234,11 @@ class TestSsyncReplication(TestBaseSsync):
|
||||
expected_subreqs['POST'].append('o3')
|
||||
|
||||
# o4 is on tx with meta, rx has older data and up to date meta
|
||||
t4a = self.ts_iter.next()
|
||||
t4a = next(self.ts_iter)
|
||||
rx_objs['o4'] = self._create_ondisk_files(rx_df_mgr, 'o4', policy, t4a)
|
||||
t4b = self.ts_iter.next()
|
||||
t4b = next(self.ts_iter)
|
||||
tx_objs['o4'] = self._create_ondisk_files(tx_df_mgr, 'o4', policy, t4b)
|
||||
t4_meta = self.ts_iter.next()
|
||||
t4_meta = next(self.ts_iter)
|
||||
metadata = {'X-Timestamp': t4_meta.internal,
|
||||
'X-Object-Meta-Test': 'o4',
|
||||
'X-Object-Sysmeta-Test': 'sys_o4'}
|
||||
@ -2247,10 +2247,10 @@ class TestSsyncReplication(TestBaseSsync):
|
||||
expected_subreqs['PUT'].append('o4')
|
||||
|
||||
# o5 is on tx with meta, rx is in sync with data and meta
|
||||
t5 = self.ts_iter.next()
|
||||
t5 = next(self.ts_iter)
|
||||
rx_objs['o5'] = self._create_ondisk_files(rx_df_mgr, 'o5', policy, t5)
|
||||
tx_objs['o5'] = self._create_ondisk_files(tx_df_mgr, 'o5', policy, t5)
|
||||
t5_meta = self.ts_iter.next()
|
||||
t5_meta = next(self.ts_iter)
|
||||
metadata = {'X-Timestamp': t5_meta.internal,
|
||||
'X-Object-Meta-Test': 'o5',
|
||||
'X-Object-Sysmeta-Test': 'sys_o5'}
|
||||
@ -2258,29 +2258,29 @@ class TestSsyncReplication(TestBaseSsync):
|
||||
rx_objs['o5'][0].write_metadata(metadata)
|
||||
|
||||
# o6 is tombstone on tx, rx has older data and meta
|
||||
t6 = self.ts_iter.next()
|
||||
t6 = next(self.ts_iter)
|
||||
tx_tombstones['o6'] = self._create_ondisk_files(
|
||||
tx_df_mgr, 'o6', policy, t6)
|
||||
rx_tombstones['o6'] = self._create_ondisk_files(
|
||||
rx_df_mgr, 'o6', policy, t6)
|
||||
metadata = {'X-Timestamp': self.ts_iter.next().internal,
|
||||
metadata = {'X-Timestamp': next(self.ts_iter).internal,
|
||||
'X-Object-Meta-Test': 'o6',
|
||||
'X-Object-Sysmeta-Test': 'sys_o6'}
|
||||
rx_tombstones['o6'][0].write_metadata(metadata)
|
||||
tx_tombstones['o6'][0].delete(self.ts_iter.next())
|
||||
tx_tombstones['o6'][0].delete(next(self.ts_iter))
|
||||
expected_subreqs['DELETE'].append('o6')
|
||||
|
||||
# o7 is tombstone on rx, tx has older data and meta,
|
||||
# no subreqs expected...
|
||||
t7 = self.ts_iter.next()
|
||||
t7 = next(self.ts_iter)
|
||||
tx_objs['o7'] = self._create_ondisk_files(tx_df_mgr, 'o7', policy, t7)
|
||||
rx_tombstones['o7'] = self._create_ondisk_files(
|
||||
rx_df_mgr, 'o7', policy, t7)
|
||||
metadata = {'X-Timestamp': self.ts_iter.next().internal,
|
||||
metadata = {'X-Timestamp': next(self.ts_iter).internal,
|
||||
'X-Object-Meta-Test': 'o7',
|
||||
'X-Object-Sysmeta-Test': 'sys_o7'}
|
||||
tx_objs['o7'][0].write_metadata(metadata)
|
||||
rx_tombstones['o7'][0].delete(self.ts_iter.next())
|
||||
rx_tombstones['o7'][0].delete(next(self.ts_iter))
|
||||
|
||||
suffixes = set()
|
||||
for diskfiles in (tx_objs.values() + tx_tombstones.values()):
|
||||
@ -2344,11 +2344,11 @@ class TestSsyncReplication(TestBaseSsync):
|
||||
|
||||
# rx has data at t1 but no meta
|
||||
# object is on tx with data at t2, meta at t3,
|
||||
t1 = self.ts_iter.next()
|
||||
t1 = next(self.ts_iter)
|
||||
self._create_ondisk_files(rx_df_mgr, 'o1', policy, t1)
|
||||
t2 = self.ts_iter.next()
|
||||
t2 = next(self.ts_iter)
|
||||
tx_obj = self._create_ondisk_files(tx_df_mgr, 'o1', policy, t2)[0]
|
||||
t3 = self.ts_iter.next()
|
||||
t3 = next(self.ts_iter)
|
||||
metadata = {'X-Timestamp': t3.internal,
|
||||
'X-Object-Meta-Test': 'o3',
|
||||
'X-Object-Sysmeta-Test': 'sys_o3'}
|
||||
@ -2422,8 +2422,8 @@ class TestModuleMethods(unittest.TestCase):
|
||||
def test_encode_missing(self):
|
||||
object_hash = '9d41d8cd98f00b204e9800998ecf0abc'
|
||||
ts_iter = make_timestamp_iter()
|
||||
t_data = ts_iter.next()
|
||||
t_meta = ts_iter.next()
|
||||
t_data = next(ts_iter)
|
||||
t_meta = next(ts_iter)
|
||||
d_meta_data = t_meta.raw - t_data.raw
|
||||
|
||||
# equal data and meta timestamps -> legacy single timestamp string
|
||||
|
@ -818,7 +818,7 @@ class TestReplicatedObjController(BaseObjectControllerMixin,
|
||||
req = swob.Request.blank(
|
||||
'/v1/a/c/o', method='PUT', headers={
|
||||
'Content-Length': 0,
|
||||
'X-Timestamp': ts.next().internal})
|
||||
'X-Timestamp': next(ts).internal})
|
||||
ts_iter = iter([None, None, None])
|
||||
codes = [409] * self.obj_ring.replicas
|
||||
with set_http_connect(*codes, timestamps=ts_iter):
|
||||
@ -830,8 +830,8 @@ class TestReplicatedObjController(BaseObjectControllerMixin,
|
||||
req = swob.Request.blank(
|
||||
'/v1/a/c/o', method='PUT', headers={
|
||||
'Content-Length': 0,
|
||||
'X-Timestamp': ts.next().internal})
|
||||
ts_iter = iter([ts.next().internal, None, None])
|
||||
'X-Timestamp': next(ts).internal})
|
||||
ts_iter = iter([next(ts).internal, None, None])
|
||||
codes = [409] + [(201, 'notused')] * (self.obj_ring.replicas - 1)
|
||||
with set_http_connect(*codes, timestamps=ts_iter):
|
||||
resp = req.get_response(self.app)
|
||||
@ -843,8 +843,8 @@ class TestReplicatedObjController(BaseObjectControllerMixin,
|
||||
'/v1/a/c/o', method='PUT', headers={
|
||||
'Content-Length': 0,
|
||||
'If-None-Match': '*',
|
||||
'X-Timestamp': ts.next().internal})
|
||||
ts_iter = iter([ts.next().internal, None, None])
|
||||
'X-Timestamp': next(ts).internal})
|
||||
ts_iter = iter([next(ts).internal, None, None])
|
||||
codes = [409] + [(412, 'notused')] * (self.obj_ring.replicas - 1)
|
||||
with set_http_connect(*codes, timestamps=ts_iter):
|
||||
resp = req.get_response(self.app)
|
||||
|
Loading…
Reference in New Issue
Block a user