Replace six.iteritems with dict.items
As [1] mentioned, we should use dict.items instead of six.iteritems.
Let's use dict.items as it should return iterators in PY3 as well.
(As for PY2, the performance about list should be negligible)
[1] https://wiki.openstack.org/wiki/Python3
Change-Id: I77b3a71faa71b5f671daff3415e2ae58289fd3ca
diff --git a/tempest/api/compute/admin/test_quotas.py b/tempest/api/compute/admin/test_quotas.py
index ce0adb4..33b9bef 100644
--- a/tempest/api/compute/admin/test_quotas.py
+++ b/tempest/api/compute/admin/test_quotas.py
@@ -14,7 +14,6 @@
# under the License.
from oslo_log import log as logging
-import six
from testtools import matchers
from tempest.api.compute import base
@@ -175,7 +174,7 @@
# restore the defaults when the test is done
self.addCleanup(self._restore_default_quotas, body.copy())
# increment all of the values for updating the default quota class
- for quota, default in six.iteritems(body):
+ for quota, default in body.items():
# NOTE(sdague): we need to increment a lot, otherwise
# there is a real chance that we go from -1 (unlimited)
# to a very small number which causes issues.
diff --git a/tempest/api/compute/servers/test_server_addresses.py b/tempest/api/compute/servers/test_server_addresses.py
index d31b6f8..549ba03 100644
--- a/tempest/api/compute/servers/test_server_addresses.py
+++ b/tempest/api/compute/servers/test_server_addresses.py
@@ -13,8 +13,6 @@
# License for the specific language governing permissions and limitations
# under the License.
-import six
-
from tempest.api.compute import base
from tempest import test
@@ -50,7 +48,7 @@
# We do not know the exact network configuration, but an instance
# should at least have a single public or private address
self.assertGreaterEqual(len(addresses), 1)
- for network_name, network_addresses in six.iteritems(addresses):
+ for network_name, network_addresses in addresses.items():
self.assertGreaterEqual(len(network_addresses), 1)
for address in network_addresses:
self.assertTrue(address['addr'])
diff --git a/tempest/api/network/admin/test_quotas.py b/tempest/api/network/admin/test_quotas.py
index 978fb8f..8695ebd 100644
--- a/tempest/api/network/admin/test_quotas.py
+++ b/tempest/api/network/admin/test_quotas.py
@@ -13,8 +13,6 @@
# License for the specific language governing permissions and limitations
# under the License.
-import six
-
from tempest.api.network import base
from tempest.common.utils import data_utils
from tempest.lib.common.utils import test_utils
@@ -57,7 +55,7 @@
project_id, **new_quotas)['quota']
self.addCleanup(test_utils.call_and_ignore_notfound_exc,
self.admin_quotas_client.reset_quotas, project_id)
- for key, value in six.iteritems(new_quotas):
+ for key, value in new_quotas.items():
self.assertEqual(value, quota_set[key])
# Confirm our project is listed among projects with non default quotas
@@ -71,7 +69,7 @@
# Confirm from API quotas were changed as requested for project
quota_set = self.admin_quotas_client.show_quotas(project_id)
quota_set = quota_set['quota']
- for key, value in six.iteritems(new_quotas):
+ for key, value in new_quotas.items():
self.assertEqual(value, quota_set[key])
# Reset quotas to default and confirm
diff --git a/tempest/api/network/test_dhcp_ipv6.py b/tempest/api/network/test_dhcp_ipv6.py
index 84c48ec..baf2b2e 100644
--- a/tempest/api/network/test_dhcp_ipv6.py
+++ b/tempest/api/network/test_dhcp_ipv6.py
@@ -16,8 +16,6 @@
import netaddr
import random
-import six
-
from tempest.api.network import base
from tempest.common.utils import data_utils
from tempest.common.utils import net_info
@@ -126,7 +124,7 @@
):
kwargs = {'ipv6_ra_mode': ra_mode,
'ipv6_address_mode': add_mode}
- kwargs = dict((k, v) for k, v in six.iteritems(kwargs) if v)
+ kwargs = dict((k, v) for k, v in kwargs.items() if v)
real_ip, eui_ip = self._get_ips_from_subnet(**kwargs)
self._clean_network()
self.assertEqual(eui_ip, real_ip,
@@ -269,7 +267,7 @@
):
kwargs = {'ipv6_ra_mode': ra_mode,
'ipv6_address_mode': add_mode}
- kwargs = dict((k, v) for k, v in six.iteritems(kwargs) if v)
+ kwargs = dict((k, v) for k, v in kwargs.items() if v)
subnet = self.create_subnet(self.network, **kwargs)
port = self.create_port(self.network)
port_ip = next(iter(port['fixed_ips']), None)['ip_address']
@@ -291,7 +289,7 @@
):
kwargs = {'ipv6_ra_mode': ra_mode,
'ipv6_address_mode': add_mode}
- kwargs = dict((k, v) for k, v in six.iteritems(kwargs) if v)
+ kwargs = dict((k, v) for k, v in kwargs.items() if v)
subnet = self.create_subnet(self.network, **kwargs)
ip_range = netaddr.IPRange(subnet["allocation_pools"][0]["start"],
subnet["allocation_pools"][0]["end"])
@@ -364,7 +362,7 @@
):
kwargs = {'ipv6_ra_mode': ra_mode,
'ipv6_address_mode': add_mode}
- kwargs = dict((k, v) for k, v in six.iteritems(kwargs) if v)
+ kwargs = dict((k, v) for k, v in kwargs.items() if v)
subnet, port = self._create_subnet_router(kwargs)
port_ip = next(iter(port['fixed_ips']), None)['ip_address']
self._clean_network()
diff --git a/tempest/api/network/test_networks.py b/tempest/api/network/test_networks.py
index acac22b..8e2f3f6 100644
--- a/tempest/api/network/test_networks.py
+++ b/tempest/api/network/test_networks.py
@@ -130,7 +130,7 @@
**kwargs)
compare_args_full = dict(gateway_ip=gateway, cidr=cidr,
mask_bits=mask_bits, **kwargs)
- compare_args = dict((k, v) for k, v in six.iteritems(compare_args_full)
+ compare_args = dict((k, v) for k, v in compare_args_full.items()
if v is not None)
if 'dns_nameservers' in set(subnet).intersection(compare_args):
diff --git a/tempest/api/network/test_routers.py b/tempest/api/network/test_routers.py
index f2170ad..101e4dd 100644
--- a/tempest/api/network/test_routers.py
+++ b/tempest/api/network/test_routers.py
@@ -14,7 +14,6 @@
# under the License.
import netaddr
-import six
from tempest.api.network import base_routers as base
from tempest.common.utils import data_utils
@@ -163,7 +162,7 @@
self.assertIsNone(actual_ext_gw_info)
return
# Verify only keys passed in exp_ext_gw_info
- for k, v in six.iteritems(exp_ext_gw_info):
+ for k, v in exp_ext_gw_info.items():
self.assertEqual(v, actual_ext_gw_info[k])
def _verify_gateway_port(self, router_id):
diff --git a/tempest/api/network/test_security_groups.py b/tempest/api/network/test_security_groups.py
index 1031ab8..be01852 100644
--- a/tempest/api/network/test_security_groups.py
+++ b/tempest/api/network/test_security_groups.py
@@ -13,8 +13,6 @@
# License for the specific language governing permissions and limitations
# under the License.
-import six
-
from tempest.api.network import base_security_groups as base
from tempest.common.utils import data_utils
from tempest import config
@@ -62,7 +60,7 @@
'port_range_max': port_range_max,
'remote_group_id': remote_group_id,
'remote_ip_prefix': remote_ip_prefix}
- for key, value in six.iteritems(expected):
+ for key, value in expected.items():
self.assertEqual(value, sec_group_rule[key],
"Field %s of the created security group "
"rule does not match with %s." %
@@ -131,7 +129,7 @@
rule_create_body['security_group_rule']['id']
)
create_dict = rule_create_body['security_group_rule']
- for key, value in six.iteritems(create_dict):
+ for key, value in create_dict.items():
self.assertEqual(value,
show_rule_body['security_group_rule'][key],
"%s does not match." % key)
diff --git a/tempest/api/object_storage/test_object_services.py b/tempest/api/object_storage/test_object_services.py
index 8736f9a..e2e9919 100644
--- a/tempest/api/object_storage/test_object_services.py
+++ b/tempest/api/object_storage/test_object_services.py
@@ -19,8 +19,6 @@
import time
import zlib
-import six
-
from tempest.api.object_storage import base
from tempest.common import custom_matchers
from tempest.common.utils import data_utils
@@ -865,7 +863,7 @@
expected = {'x-object-meta-test': '',
'x-object-meta-src': 'src_value',
'x-copied-from': self.container_name + "/" + src_obj_name}
- for key, value in six.iteritems(expected):
+ for key, value in expected.items():
self.assertIn(key, resp)
self.assertEqual(value, resp[key])
@@ -888,7 +886,7 @@
expected = {'x-object-meta-test': 'value',
'x-object-meta-src': 'src_value',
'x-copied-from': self.container_name + "/" + src_obj_name}
- for key, value in six.iteritems(expected):
+ for key, value in expected.items():
self.assertIn(key, resp)
self.assertEqual(value, resp[key])
diff --git a/tempest/api/volume/admin/test_volume_quotas.py b/tempest/api/volume/admin/test_volume_quotas.py
index b47a5f0..7d8c94d 100644
--- a/tempest/api/volume/admin/test_volume_quotas.py
+++ b/tempest/api/volume/admin/test_volume_quotas.py
@@ -12,7 +12,6 @@
# License for the specific language governing permissions and limitations
# under the License.
-import six
from tempest.api.volume import base
from tempest.common.utils import data_utils
from tempest.common import waiters
@@ -63,7 +62,7 @@
**new_quota_set)['quota_set']
cleanup_quota_set = dict(
- (k, v) for k, v in six.iteritems(default_quota_set)
+ (k, v) for k, v in default_quota_set.items()
if k in QUOTA_KEYS)
self.addCleanup(self.admin_quotas_client.update_quota_set,
self.demo_tenant_id, **cleanup_quota_set)
diff --git a/tempest/common/custom_matchers.py b/tempest/common/custom_matchers.py
index 8410541..ed11b21 100644
--- a/tempest/common/custom_matchers.py
+++ b/tempest/common/custom_matchers.py
@@ -14,7 +14,6 @@
import re
-import six
from testtools import helpers
@@ -217,7 +216,7 @@
"""
def match(self, actual):
- for key, value in six.iteritems(actual):
+ for key, value in actual.items():
if key in ('content-length', 'x-account-bytes-used',
'x-account-container-count', 'x-account-object-count',
'x-container-bytes-used', 'x-container-object-count')\
diff --git a/tempest/common/image.py b/tempest/common/image.py
index 95a7d1a..3618f7e 100644
--- a/tempest/common/image.py
+++ b/tempest/common/image.py
@@ -15,8 +15,6 @@
import copy
-import six
-
def get_image_meta_from_headers(resp):
meta = {'properties': {}}
@@ -55,13 +53,13 @@
if copy_from is not None:
headers['x-glance-api-copy-from'] = copy_from
- for key, value in six.iteritems(fields_copy.pop('properties', {})):
+ for key, value in fields_copy.pop('properties', {}).items():
headers['x-image-meta-property-%s' % key] = str(value)
- for key, value in six.iteritems(fields_copy.pop('api', {})):
+ for key, value in fields_copy.pop('api', {}).items():
headers['x-glance-api-property-%s' % key] = str(value)
- for key, value in six.iteritems(fields_copy):
+ for key, value in fields_copy.items():
headers['x-image-meta-%s' % key] = str(value)
return headers
diff --git a/tempest/common/preprov_creds.py b/tempest/common/preprov_creds.py
index 3f68ae8..969a978 100644
--- a/tempest/common/preprov_creds.py
+++ b/tempest/common/preprov_creds.py
@@ -120,7 +120,7 @@
if 'resources' in account:
resources = account.pop('resources')
temp_hash = hashlib.md5()
- account_for_hash = dict((k, v) for (k, v) in six.iteritems(account)
+ account_for_hash = dict((k, v) for (k, v) in account.items()
if k in cls.HASH_CRED_FIELDS)
temp_hash.update(six.text_type(account_for_hash).encode('utf-8'))
temp_hash_key = temp_hash.hexdigest()
diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py
index 376dd19..e4e2794 100644
--- a/tempest/scenario/manager.py
+++ b/tempest/scenario/manager.py
@@ -20,7 +20,6 @@
from oslo_log import log
from oslo_serialization import jsonutils as json
from oslo_utils import netutils
-import six
from tempest.common import compute
from tempest.common import image as common_image
@@ -920,7 +919,7 @@
# The target login is assumed to have been configured for
# key-based authentication by cloud-init.
try:
- for net_name, ip_addresses in six.iteritems(server['addresses']):
+ for net_name, ip_addresses in server['addresses'].items():
for ip_address in ip_addresses:
self.check_vm_connectivity(ip_address['addr'],
username,
diff --git a/tempest/scenario/test_network_v6.py b/tempest/scenario/test_network_v6.py
index 40b3317..7acf107 100644
--- a/tempest/scenario/test_network_v6.py
+++ b/tempest/scenario/test_network_v6.py
@@ -14,8 +14,6 @@
# under the License.
import functools
-import six
-
from tempest import config
from tempest.lib.common.utils import test_utils
from tempest.scenario import manager
@@ -112,7 +110,7 @@
@staticmethod
def define_server_ips(srv):
ips = {'4': None, '6': []}
- for net_name, nics in six.iteritems(srv['addresses']):
+ for net_name, nics in srv['addresses'].items():
for nic in nics:
if nic['version'] == 6:
ips['6'].append(nic['addr'])
diff --git a/tempest/services/object_storage/object_client.py b/tempest/services/object_storage/object_client.py
index 9445e34..6d656ec 100644
--- a/tempest/services/object_storage/object_client.py
+++ b/tempest/services/object_storage/object_client.py
@@ -13,7 +13,6 @@
# License for the specific language governing permissions and limitations
# under the License.
-import six
from six.moves import http_client as httplib
from six.moves.urllib import parse as urlparse
@@ -189,7 +188,7 @@
# Send the PUT request and the headers including the "Expect" header
conn.putrequest('PUT', path)
- for header, value in six.iteritems(headers):
+ for header, value in headers.items():
conn.putheader(header, value)
conn.endheaders()
diff --git a/tempest/tests/common/test_preprov_creds.py b/tempest/tests/common/test_preprov_creds.py
index f824b6c..1c9982c 100644
--- a/tempest/tests/common/test_preprov_creds.py
+++ b/tempest/tests/common/test_preprov_creds.py
@@ -101,7 +101,7 @@
preprov_creds.PreProvisionedCredentialProvider.HASH_CRED_FIELDS)
for account in accounts_list:
hash = hashlib.md5()
- account_for_hash = dict((k, v) for (k, v) in six.iteritems(account)
+ account_for_hash = dict((k, v) for (k, v) in account.items()
if k in hash_fields)
hash.update(six.text_type(account_for_hash).encode('utf-8'))
temp_hash = hash.hexdigest()
diff --git a/tempest/tests/services/object_storage/test_object_client.py b/tempest/tests/services/object_storage/test_object_client.py
index cc1dc1a..748614c 100644
--- a/tempest/tests/services/object_storage/test_object_client.py
+++ b/tempest/tests/services/object_storage/test_object_client.py
@@ -15,7 +15,6 @@
import mock
-import six
from tempest.lib import exceptions
from tempest.services.object_storage import object_client
@@ -85,7 +84,7 @@
# Verify that headers were written, including "Expect:100-continue"
calls = []
- for header, value in six.iteritems(expected_hdrs):
+ for header, value in expected_hdrs.items():
calls.append(mock.call(header, value))
mock_poc.return_value.putheader.assert_has_calls(calls, False)