Replace filter() with list-comprehension
Replace filter() with list-comprehension when a list is expected. On Python 3, filter() returns an iterator, not a list. tox.ini: add openstack admin volume tests to Python 3.4. Partial-Implements: blueprint porting-python3 Change-Id: Id99124bf0ef5549c596d94f5d10ab5f88a4e200a
This commit is contained in:
parent
8d08abdc9f
commit
2d993b4acc
@ -64,7 +64,7 @@ class GlobalOverview(usage.UsageView):
|
|||||||
exceptions.handle(self.request,
|
exceptions.handle(self.request,
|
||||||
_('Unable to retrieve project list.'))
|
_('Unable to retrieve project list.'))
|
||||||
for instance in data:
|
for instance in data:
|
||||||
project = filter(lambda t: t.id == instance.tenant_id, projects)
|
project = [t for t in projects if t.id == instance.tenant_id]
|
||||||
# If we could not get the project name, show the tenant_id with
|
# If we could not get the project name, show the tenant_id with
|
||||||
# a 'Deleted' identifier instead.
|
# a 'Deleted' identifier instead.
|
||||||
if project:
|
if project:
|
||||||
|
@ -89,8 +89,8 @@ class VolumeViewTests(test.BaseAdminViewTests):
|
|||||||
'volume_get')})
|
'volume_get')})
|
||||||
def test_unmanage_volume(self):
|
def test_unmanage_volume(self):
|
||||||
# important - need to get the v2 cinder volume which has host data
|
# important - need to get the v2 cinder volume which has host data
|
||||||
volume_list = \
|
volume_list = [x for x in self.cinder_volumes.list()
|
||||||
filter(lambda x: x.name == 'v2_volume', self.cinder_volumes.list())
|
if x.name == 'v2_volume']
|
||||||
volume = volume_list[0]
|
volume = volume_list[0]
|
||||||
formData = {'volume_name': volume.name,
|
formData = {'volume_name': volume.name,
|
||||||
'host_name': 'host@backend-name#pool',
|
'host_name': 'host@backend-name#pool',
|
||||||
|
@ -251,10 +251,10 @@ def check_rule_template(port, ip_proto):
|
|||||||
rules_dict = getattr(settings, 'SECURITY_GROUP_RULES', {})
|
rules_dict = getattr(settings, 'SECURITY_GROUP_RULES', {})
|
||||||
if not rules_dict:
|
if not rules_dict:
|
||||||
return port
|
return port
|
||||||
templ_rule = filter(lambda rule: str(port) == rule['from_port']
|
templ_rule = [rule for rule in rules_dict.values()
|
||||||
|
if (str(port) == rule['from_port']
|
||||||
and str(port) == rule['to_port']
|
and str(port) == rule['to_port']
|
||||||
and ip_proto == rule['ip_protocol'],
|
and ip_proto == rule['ip_protocol'])]
|
||||||
[rule for rule in rules_dict.values()])
|
|
||||||
if templ_rule:
|
if templ_rule:
|
||||||
return u"%(from_port)s (%(name)s)" % templ_rule[0]
|
return u"%(from_port)s (%(name)s)" % templ_rule[0]
|
||||||
return port
|
return port
|
||||||
|
@ -314,7 +314,7 @@ def _get_tenant_network_usages(request, usages, disabled_quotas, tenant_id):
|
|||||||
networks = []
|
networks = []
|
||||||
networks = neutron.network_list(request, shared=False)
|
networks = neutron.network_list(request, shared=False)
|
||||||
if tenant_id:
|
if tenant_id:
|
||||||
networks = filter(lambda net: net.tenant_id == tenant_id, networks)
|
networks = [net for net in networks if net.tenant_id == tenant_id]
|
||||||
usages.tally('networks', len(networks))
|
usages.tally('networks', len(networks))
|
||||||
|
|
||||||
if 'subnet' not in disabled_quotas:
|
if 'subnet' not in disabled_quotas:
|
||||||
|
1
tox.ini
1
tox.ini
@ -34,6 +34,7 @@ commands =
|
|||||||
horizon.test.tests.utils \
|
horizon.test.tests.utils \
|
||||||
horizon.test.tests.views
|
horizon.test.tests.views
|
||||||
python manage.py test --settings=openstack_dashboard.test.settings \
|
python manage.py test --settings=openstack_dashboard.test.settings \
|
||||||
|
openstack_dashboard.dashboards.admin.volumes.volumes.tests \
|
||||||
openstack_dashboard.dashboards.identity.users \
|
openstack_dashboard.dashboards.identity.users \
|
||||||
openstack_dashboard.dashboards.project.access_and_security.api_access.tests \
|
openstack_dashboard.dashboards.project.access_and_security.api_access.tests \
|
||||||
openstack_dashboard.dashboards.project.images.images.tests.CreateImageFormTests \
|
openstack_dashboard.dashboards.project.images.images.tests.CreateImageFormTests \
|
||||||
|
Loading…
Reference in New Issue
Block a user