Prevent use filter(lambda obj: test(obj), data)
In Python3 [1], if we need filter on python3, replace
filter(lambda obj: test(obj), data) with:
[obj for obj in data if test(obj)]. This patch replaces
filter function and introduces a hacking rule to prevent
using filter in future.
[1] https://wiki.openstack.org/wiki/Python3
Change-Id: I83d22108c02f8da007a7233e71a4a7fb833170ec
diff --git a/neutron/tests/tempest/api/test_subnetpools.py b/neutron/tests/tempest/api/test_subnetpools.py
index 5bd222f..a7a523e 100644
--- a/neutron/tests/tempest/api/test_subnetpools.py
+++ b/neutron/tests/tempest/api/test_subnetpools.py
@@ -110,13 +110,15 @@
body = self._create_subnetpool(description='d1')
self.assertEqual('d1', body['description'])
sub_id = body['id']
- body = filter(lambda x: x['id'] == sub_id,
- self.client.list_subnetpools()['subnetpools'])[0]
+ subnet_pools = [x for x in
+ self.client.list_subnetpools()['subnetpools'] if x['id'] == sub_id]
+ body = subnet_pools[0]
self.assertEqual('d1', body['description'])
body = self.client.update_subnetpool(sub_id, description='d2')
self.assertEqual('d2', body['subnetpool']['description'])
- body = filter(lambda x: x['id'] == sub_id,
- self.client.list_subnetpools()['subnetpools'])[0]
+ subnet_pools = [x for x in
+ self.client.list_subnetpools()['subnetpools'] if x['id'] == sub_id]
+ body = subnet_pools[0]
self.assertEqual('d2', body['description'])
@test.idempotent_id('741d08c2-1e3f-42be-99c7-0ea93c5b728c')