Replace six.iteritems() with .items()
1.As mentioned in [1], we should avoid using six.iteritems to achieve iterators. We can use dict.items instead, as it will return iterators in PY3 as well. And dict.items/keys will more readable. 2.In py2, the performance about list should be negligible, see the link [2]. [1] https://wiki.openstack.org/wiki/Python3 [2] http://lists.openstack.org/pipermail/openstack-dev/2015-June /066391.html Change-Id: Icfc0998c77b4d9c2112af331d21ec5b41fd7de50
This commit is contained in:
parent
4923182db3
commit
4c72f8233c
|
@ -15,7 +15,6 @@
|
|||
import uuid
|
||||
|
||||
import mock
|
||||
import six
|
||||
import webob
|
||||
import webob.exc
|
||||
|
||||
|
@ -161,7 +160,7 @@ class TestComputeController(base.TestController):
|
|||
}
|
||||
|
||||
req = self._build_req(tenant["id"], path="/foo?action=start")
|
||||
for state, action in six.iteritems(state_action_map):
|
||||
for state, action in state_action_map.items():
|
||||
req.get_parser = mock.MagicMock()
|
||||
server_uuid = uuid.uuid4().hex
|
||||
server = {"status": state}
|
||||
|
|
|
@ -17,7 +17,6 @@ import json
|
|||
import uuid
|
||||
|
||||
import mock
|
||||
import six
|
||||
import webob
|
||||
|
||||
from ooi.api import helpers
|
||||
|
@ -114,7 +113,7 @@ class TestExceptionHelper(base.TestCase):
|
|||
503: webob.exc.HTTPServiceUnavailable,
|
||||
}
|
||||
|
||||
for code, exception in six.iteritems(code_and_exception):
|
||||
for code, exception in code_and_exception.items():
|
||||
fault = self.get_fault(code)
|
||||
resp = fakes.create_fake_json_resp(fault, code)
|
||||
ret = helpers.exception_from_response(resp)
|
||||
|
@ -131,7 +130,7 @@ class TestExceptionHelper(base.TestCase):
|
|||
"http://bugs.launchpad.net/ooi/ and attach the "
|
||||
"ooi API log if possible.")
|
||||
|
||||
for code, exception in six.iteritems(code_and_exception):
|
||||
for code, exception in code_and_exception.items():
|
||||
fault = self.get_fault(code)
|
||||
resp = fakes.create_fake_json_resp(fault, code)
|
||||
ret = helpers.exception_from_response(resp)
|
||||
|
@ -895,7 +894,7 @@ class TestOpenStackHelperReqs(TestBaseHelper):
|
|||
|
||||
path = "/%s/servers/%s/action" % (tenant["id"], server_uuid)
|
||||
|
||||
for act, body in six.iteritems(actions_map):
|
||||
for act, body in actions_map.items():
|
||||
os_req = self.helper._get_run_action_req(req, act, server_uuid)
|
||||
self.assertExpectedReq("POST", path, body, os_req)
|
||||
|
||||
|
@ -917,7 +916,7 @@ class TestOpenStackHelperReqs(TestBaseHelper):
|
|||
path = "/%s/servers/%s/action" % (tenant["id"], server_uuid)
|
||||
|
||||
action_args = {"foo": "bar"}
|
||||
for act, os_act in six.iteritems(actions_map):
|
||||
for act, os_act in actions_map.items():
|
||||
os_req = self.helper._get_run_action_req(req, act, server_uuid,
|
||||
action_args)
|
||||
self.assertExpectedReq("POST", path, {os_act: action_args}, os_req)
|
||||
|
|
Loading…
Reference in New Issue