Replace six.iteritems() with .items()
1.As mentioned in [1], we should avoid usingg 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: I71c13040318eca6e5ed993e8aa03f8003986a71c
This commit is contained in:
@@ -134,7 +134,7 @@ class TestClient(testtools.TestCase):
|
||||
http_client.get(path)
|
||||
|
||||
headers = self.mock.last_request.headers
|
||||
for k, v in six.iteritems(identity_headers):
|
||||
for k, v in identity_headers.items():
|
||||
self.assertEqual(v, headers[k])
|
||||
|
||||
def test_language_header_passed(self):
|
||||
@@ -326,7 +326,7 @@ class TestClient(testtools.TestCase):
|
||||
'LOG.debug called with no arguments')
|
||||
|
||||
needles = {'key': key, 'cert': cert, 'cacert': cacert}
|
||||
for option, value in six.iteritems(needles):
|
||||
for option, value in needles.items():
|
||||
if value:
|
||||
regex = ".*\s--%s\s+('%s'|%s).*" % (option, value, value)
|
||||
self.assertThat(mock_log.call_args[0][0],
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import six
|
||||
import testtools
|
||||
|
||||
from glanceclient.tests.unit.v2 import base
|
||||
@@ -276,7 +275,7 @@ class TestObjectController(testtools.TestCase):
|
||||
obj = self.controller.get(NAMESPACE1, OBJECT1)
|
||||
self.assertEqual(OBJECT1, obj.name)
|
||||
self.assertEqual(sorted([PROPERTY1, PROPERTY2]),
|
||||
sorted(list(six.iterkeys(obj.properties))))
|
||||
sorted(list(obj.properties.keys())))
|
||||
|
||||
def test_create_object(self):
|
||||
properties = {
|
||||
|
||||
Reference in New Issue
Block a user