Use six.iteritems() in for loop
Use six.iteritems() in for loop. Use next() built-in function to return next item. Partial implements: blueprint py33-support Change-Id: Idff28608232ad9a41dc63d397d88e363ffde8193
This commit is contained in:
@@ -17,6 +17,7 @@ import json
|
|||||||
import optparse
|
import optparse
|
||||||
import os
|
import os
|
||||||
import pickle
|
import pickle
|
||||||
|
import six
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from troveclient.compat import client
|
from troveclient.compat import client
|
||||||
@@ -44,7 +45,7 @@ def check_for_exceptions(resp, body):
|
|||||||
def print_actions(cmd, actions):
|
def print_actions(cmd, actions):
|
||||||
"""Print help for the command with list of options and description"""
|
"""Print help for the command with list of options and description"""
|
||||||
print(("Available actions for '%s' cmd:") % cmd)
|
print(("Available actions for '%s' cmd:") % cmd)
|
||||||
for k, v in actions.iteritems():
|
for k, v in six.iteritems(actions):
|
||||||
print("\t%-20s%s" % (k, v.__doc__))
|
print("\t%-20s%s" % (k, v.__doc__))
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|
||||||
@@ -53,7 +54,7 @@ def print_commands(commands):
|
|||||||
"""Print the list of available commands and description"""
|
"""Print the list of available commands and description"""
|
||||||
|
|
||||||
print("Available commands")
|
print("Available commands")
|
||||||
for k, v in commands.iteritems():
|
for k, v in six.iteritems(commands):
|
||||||
print("\t%-20s%s" % (k, v.__doc__))
|
print("\t%-20s%s" % (k, v.__doc__))
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|
||||||
|
|||||||
@@ -355,10 +355,10 @@ class PaginatedTest(TestCase):
|
|||||||
def test___iter__(self):
|
def test___iter__(self):
|
||||||
itr_expected = self.items_.__iter__()
|
itr_expected = self.items_.__iter__()
|
||||||
itr = self.pgn.__iter__()
|
itr = self.pgn.__iter__()
|
||||||
self.assertEqual(itr_expected.next(), itr.next())
|
self.assertEqual(next(itr_expected), next(itr))
|
||||||
self.assertEqual(itr_expected.next(), itr.next())
|
self.assertEqual(next(itr_expected), next(itr))
|
||||||
self.assertRaises(StopIteration, itr_expected.next)
|
self.assertRaises(StopIteration, next, itr_expected)
|
||||||
self.assertRaises(StopIteration, itr.next)
|
self.assertRaises(StopIteration, next, itr)
|
||||||
|
|
||||||
def test___getitem__(self):
|
def test___getitem__(self):
|
||||||
self.assertEqual(self.items_[0], self.pgn.__getitem__(0))
|
self.assertEqual(self.items_[0], self.pgn.__getitem__(0))
|
||||||
@@ -374,9 +374,9 @@ class PaginatedTest(TestCase):
|
|||||||
def test___reversed__(self):
|
def test___reversed__(self):
|
||||||
itr = self.pgn.__reversed__()
|
itr = self.pgn.__reversed__()
|
||||||
expected = ["item2", "item1"]
|
expected = ["item2", "item1"]
|
||||||
self.assertEqual("item2", itr.next())
|
self.assertEqual("item2", next(itr))
|
||||||
self.assertEqual("item1", itr.next())
|
self.assertEqual("item1", next(itr))
|
||||||
self.assertRaises(StopIteration, itr.next)
|
self.assertRaises(StopIteration, next, itr)
|
||||||
|
|
||||||
def test___contains__(self):
|
def test___contains__(self):
|
||||||
self.assertTrue(self.pgn.__contains__("item1"))
|
self.assertTrue(self.pgn.__contains__("item1"))
|
||||||
|
|||||||
Reference in New Issue
Block a user