Skip to content

Commit

Permalink
Merge "Fix using filter() to meet python2,3"
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins authored and openstack-gerrit committed Aug 30, 2016
2 parents 938d0fd + 3d9de24 commit bebc86b
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion nova/tests/unit/objects/test_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def test_get_with_expected(self, mock_get, mock_fault_get, mock_extra_get):
exp_cols.remove('migration_context')
exp_cols.remove('keypairs')
exp_cols.remove('device_metadata')
exp_cols = list(filter(lambda x: 'flavor' not in x, exp_cols))
exp_cols = [exp_col for exp_col in exp_cols if 'flavor' not in exp_col]
exp_cols.extend(['extra', 'extra.numa_topology', 'extra.pci_requests',
'extra.flavor', 'extra.vcpu_model',
'extra.migration_context', 'extra.keypairs',
Expand Down
3 changes: 1 addition & 2 deletions nova/tests/unit/virt/libvirt/test_firewall.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,7 @@ def fake_iptables_execute(*cmd, **kwargs):
self.fw.prepare_instance_filter(instance_ref, network_model)
self.fw.apply_instance_filter(instance_ref, network_model)

in_rules = filter(lambda l: not l.startswith('#'),
self.in_rules)
in_rules = [l for l in self.in_rules if not l.startswith('#')]
for rule in in_rules:
if 'nova' not in rule:
self.assertIn(rule, self.out_rules,
Expand Down
2 changes: 1 addition & 1 deletion nova/tests/unit/virt/vmwareapi/fake.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def get(self, attr):

def delete(self, attr):
"""Deletes an attribute."""
self.propSet = filter(lambda elem: elem.name != attr, self.propSet)
self.propSet = [elem for elem in self.propSet if elem.name != attr]

def __setattr__(self, attr, val):
# TODO(hartsocks): this is adds unnecessary complexity to the class
Expand Down
3 changes: 1 addition & 2 deletions nova/tests/unit/virt/xenapi/test_xenapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -2728,8 +2728,7 @@ def _create_test_security_group(self):
return secgroup

def _validate_security_group(self):
in_rules = filter(lambda l: not l.startswith('#'),
self._in_rules)
in_rules = [l for l in self._in_rules if not l.startswith('#')]
for rule in in_rules:
if 'nova' not in rule:
self.assertIn(rule, self._out_rules,
Expand Down

0 comments on commit bebc86b

Please sign in to comment.