Fix using filter() to meet python2,3
As mentioned in link[1], if we need filter on python3, Raplace filter(lambda obj: test(obj), data) with: [obj for obj in data if test(obj)]. [1] https://wiki.openstack.org/wiki/Python3 Change-Id: Ia1ea2ec89e4beb957a4cb358b0d0cef970f23e0a
This commit is contained in:
parent
dd512a3207
commit
19a684dded
@ -795,8 +795,8 @@ class TestContainerBroker(unittest.TestCase):
|
||||
if isinstance(self, ContainerBrokerMigrationMixin):
|
||||
real_storage_policy_index = \
|
||||
broker.get_info()['storage_policy_index']
|
||||
policy = filter(lambda p: p.idx == real_storage_policy_index,
|
||||
POLICIES)[0]
|
||||
policy = [p for p in POLICIES
|
||||
if p.idx == real_storage_policy_index][0]
|
||||
broker.put_object('correct_o', next(ts), 123, 'text/plain',
|
||||
'5af83e3196bf99f440f31f2e1a6c9afe',
|
||||
storage_policy_index=policy.idx)
|
||||
@ -823,8 +823,8 @@ class TestContainerBroker(unittest.TestCase):
|
||||
if isinstance(self, ContainerBrokerMigrationMixin):
|
||||
real_storage_policy_index = \
|
||||
broker.get_info()['storage_policy_index']
|
||||
policy = filter(lambda p: p.idx == real_storage_policy_index,
|
||||
POLICIES)[0]
|
||||
policy = [p for p in POLICIES
|
||||
if p.idx == real_storage_policy_index][0]
|
||||
broker.put_object('correct_o', next(ts), 123, 'text/plain',
|
||||
'5af83e3196bf99f440f31f2e1a6c9afe',
|
||||
storage_policy_index=policy.idx)
|
||||
@ -847,8 +847,8 @@ class TestContainerBroker(unittest.TestCase):
|
||||
if isinstance(self, ContainerBrokerMigrationMixin):
|
||||
real_storage_policy_index = \
|
||||
broker.get_info()['storage_policy_index']
|
||||
policy = filter(lambda p: p.idx == real_storage_policy_index,
|
||||
POLICIES)[0]
|
||||
policy = [p for p in POLICIES
|
||||
if p.idx == real_storage_policy_index][0]
|
||||
policy_stats = broker.get_policy_stats()
|
||||
expected = {policy.idx: {'bytes_used': 0, 'object_count': 0}}
|
||||
self.assertEqual(policy_stats, expected)
|
||||
|
@ -4945,7 +4945,7 @@ class TestObjectController(unittest.TestCase):
|
||||
expected)
|
||||
# check that no coro was left waiting to write
|
||||
self.assertTrue(timeouts) # sanity - WrappedTimeout did get called
|
||||
missing_exits = filter(lambda tb: tb is not None, timeouts.values())
|
||||
missing_exits = [tb for tb in timeouts.values() if tb is not None]
|
||||
self.assertFalse(
|
||||
missing_exits, 'Failed to exit all ChunkWriteTimeouts.\n' +
|
||||
''.join(['No exit from ChunkWriteTimeout entered at:\n' +
|
||||
|
Loading…
Reference in New Issue
Block a user