Change instances of x.next() to next(x)
partial blueprint heat-python34-support Change-Id: Idf74dd430782ee3df90c6bb88432084187e0c089
This commit is contained in:
parent
8a3aac038b
commit
8d3f96929a
@ -64,7 +64,7 @@ class FakeAutoScale(object):
|
||||
|
||||
def create(self, **kwargs):
|
||||
"""Create a scaling group."""
|
||||
new_id = str(self.group_counter.next())
|
||||
new_id = str(next(self.group_counter))
|
||||
fsg = FakeScalingGroup(new_id, **kwargs)
|
||||
self.groups[new_id] = fsg
|
||||
return fsg
|
||||
@ -119,7 +119,7 @@ class FakeAutoScale(object):
|
||||
'scaling_group', 'name', 'policy_type', 'cooldown', 'change',
|
||||
'is_percent', 'desired_capacity', 'args']
|
||||
self._check_args(kwargs, allowed)
|
||||
policy_id = str(self.policy_counter.next())
|
||||
policy_id = str(next(self.policy_counter))
|
||||
policy = FakeScalePolicy(policy_id, **kwargs)
|
||||
self.policies[policy_id] = policy
|
||||
return policy
|
||||
@ -138,7 +138,7 @@ class FakeAutoScale(object):
|
||||
"""Create and store a FakeWebHook."""
|
||||
allowed = ['scaling_group', 'policy', 'name', 'metadata']
|
||||
self._check_args(kwargs, allowed)
|
||||
webhook_id = str(self.webhook_counter.next())
|
||||
webhook_id = str(next(self.webhook_counter))
|
||||
webhook = FakeWebHook(webhook_id, **kwargs)
|
||||
self.webhooks[webhook_id] = webhook
|
||||
return webhook
|
||||
@ -399,7 +399,7 @@ Resources:
|
||||
delete_counter = itertools.count()
|
||||
|
||||
def delete(group_id):
|
||||
count = delete_counter.next()
|
||||
count = next(delete_counter)
|
||||
if count < 3:
|
||||
raise auto_scale.Forbidden("Not empty!")
|
||||
|
||||
@ -407,7 +407,7 @@ Resources:
|
||||
resource = self.stack['my_group']
|
||||
scheduler.TaskRunner(resource.delete)()
|
||||
# It really called delete until it succeeded:
|
||||
self.assertEqual(4, delete_counter.next())
|
||||
self.assertEqual(4, next(delete_counter))
|
||||
|
||||
def test_delete_blows_up_on_other_errors(self):
|
||||
"""
|
||||
|
@ -61,7 +61,7 @@ def upgrade(migrate_engine):
|
||||
sqlalchemy.sql.expression.asc(
|
||||
event_table.c.created_at)).execute().fetchall()
|
||||
for event in event_list:
|
||||
values = {'tmp_id': fake_autoincrement.next(), 'uuid': event.id}
|
||||
values = {'tmp_id': next(fake_autoincrement), 'uuid': event.id}
|
||||
update = event_table.update().where(
|
||||
event_table.c.id == event.id).values(values)
|
||||
migrate_engine.execute(update)
|
||||
|
@ -134,7 +134,7 @@ def upgrade_resource(migrate_engine):
|
||||
sqlalchemy.sql.expression.asc(
|
||||
res_table.c.created_at)).execute().fetchall()
|
||||
for res in res_list:
|
||||
values = {'tmp_id': fake_autoincrement.next(), 'uuid': res.id}
|
||||
values = {'tmp_id': next(fake_autoincrement), 'uuid': res.id}
|
||||
update = res_table.update().where(
|
||||
res_table.c.id == res.id).values(values)
|
||||
migrate_engine.execute(update)
|
||||
|
@ -11,6 +11,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import functools
|
||||
import itertools
|
||||
|
||||
from heat.common import short_id
|
||||
@ -23,7 +24,9 @@ class ResourceTemplatesTest(common.HeatTestCase):
|
||||
def setUp(self):
|
||||
super(ResourceTemplatesTest, self).setUp()
|
||||
ids = ('stubbed-id-%s' % (i,) for i in itertools.count())
|
||||
self.patchobject(short_id, 'generate_id').side_effect = ids.next
|
||||
self.patchobject(
|
||||
short_id, 'generate_id').side_effect = functools.partial(next,
|
||||
ids)
|
||||
|
||||
def test_create_template(self):
|
||||
"""
|
||||
|
@ -1002,8 +1002,8 @@ class WrapperTaskTest(common.HeatTestCase):
|
||||
self.fail('No exception raised in parent_task')
|
||||
|
||||
task = parent_task()
|
||||
task.next()
|
||||
self.assertRaises(MyException, task.next)
|
||||
next(task)
|
||||
self.assertRaises(MyException, next, task)
|
||||
|
||||
def test_child_exception_exit(self):
|
||||
class MyException(Exception):
|
||||
@ -1024,8 +1024,8 @@ class WrapperTaskTest(common.HeatTestCase):
|
||||
self.fail('No exception raised in parent_task')
|
||||
|
||||
task = parent_task()
|
||||
task.next()
|
||||
self.assertRaises(StopIteration, task.next)
|
||||
next(task)
|
||||
self.assertRaises(StopIteration, next, task)
|
||||
|
||||
def test_child_exception_swallow(self):
|
||||
class MyException(Exception):
|
||||
@ -1048,8 +1048,8 @@ class WrapperTaskTest(common.HeatTestCase):
|
||||
yield
|
||||
|
||||
task = parent_task()
|
||||
task.next()
|
||||
task.next()
|
||||
next(task)
|
||||
next(task)
|
||||
|
||||
def test_child_exception_swallow_next(self):
|
||||
class MyException(Exception):
|
||||
@ -1074,7 +1074,7 @@ class WrapperTaskTest(common.HeatTestCase):
|
||||
yield dummy()
|
||||
|
||||
task = parent_task()
|
||||
task.next()
|
||||
next(task)
|
||||
|
||||
self.m.StubOutWithMock(dummy, 'do_step')
|
||||
for i in range(1, dummy.num_steps + 1):
|
||||
@ -1082,8 +1082,8 @@ class WrapperTaskTest(common.HeatTestCase):
|
||||
self.m.ReplayAll()
|
||||
|
||||
for i in range(1, dummy.num_steps + 1):
|
||||
task.next()
|
||||
self.assertRaises(StopIteration, task.next)
|
||||
next(task)
|
||||
self.assertRaises(StopIteration, next, task)
|
||||
|
||||
def test_thrown_exception_swallow_next(self):
|
||||
class MyException(Exception):
|
||||
@ -1115,8 +1115,8 @@ class WrapperTaskTest(common.HeatTestCase):
|
||||
task.throw(MyException)
|
||||
|
||||
for i in range(2, dummy.num_steps + 1):
|
||||
task.next()
|
||||
self.assertRaises(StopIteration, task.next)
|
||||
next(task)
|
||||
self.assertRaises(StopIteration, next, task)
|
||||
|
||||
def test_thrown_exception_raise(self):
|
||||
class MyException(Exception):
|
||||
@ -1151,8 +1151,8 @@ class WrapperTaskTest(common.HeatTestCase):
|
||||
task.throw(MyException)
|
||||
|
||||
for i in range(2, dummy.num_steps + 1):
|
||||
task.next()
|
||||
self.assertRaises(StopIteration, task.next)
|
||||
next(task)
|
||||
self.assertRaises(StopIteration, next, task)
|
||||
|
||||
def test_thrown_exception_exit(self):
|
||||
class MyException(Exception):
|
||||
@ -1185,8 +1185,8 @@ class WrapperTaskTest(common.HeatTestCase):
|
||||
task.throw(MyException)
|
||||
|
||||
for i in range(2, dummy.num_steps + 1):
|
||||
task.next()
|
||||
self.assertRaises(StopIteration, task.next)
|
||||
next(task)
|
||||
self.assertRaises(StopIteration, next, task)
|
||||
|
||||
def test_parent_exception(self):
|
||||
class MyException(Exception):
|
||||
@ -1201,8 +1201,8 @@ class WrapperTaskTest(common.HeatTestCase):
|
||||
raise MyException()
|
||||
|
||||
task = parent_task()
|
||||
task.next()
|
||||
self.assertRaises(MyException, task.next)
|
||||
next(task)
|
||||
self.assertRaises(MyException, next, task)
|
||||
|
||||
def test_parent_throw(self):
|
||||
class MyException(Exception):
|
||||
@ -1218,7 +1218,7 @@ class WrapperTaskTest(common.HeatTestCase):
|
||||
self.fail('No exception raised in parent_task')
|
||||
|
||||
task = parent_task()
|
||||
task.next()
|
||||
next(task)
|
||||
self.assertRaises(MyException, task.throw, MyException())
|
||||
|
||||
def test_parent_throw_exit(self):
|
||||
@ -1235,7 +1235,7 @@ class WrapperTaskTest(common.HeatTestCase):
|
||||
self.fail('No exception raised in parent_task')
|
||||
|
||||
task = parent_task()
|
||||
task.next()
|
||||
next(task)
|
||||
self.assertRaises(StopIteration, task.throw, MyException())
|
||||
|
||||
def test_parent_cancel(self):
|
||||
@ -1249,7 +1249,7 @@ class WrapperTaskTest(common.HeatTestCase):
|
||||
self.fail('parent_task not closed')
|
||||
|
||||
task = parent_task()
|
||||
task.next()
|
||||
next(task)
|
||||
task.close()
|
||||
|
||||
def test_parent_cancel_exit(self):
|
||||
@ -1263,7 +1263,7 @@ class WrapperTaskTest(common.HeatTestCase):
|
||||
self.fail('parent_task not closed')
|
||||
|
||||
task = parent_task()
|
||||
task.next()
|
||||
next(task)
|
||||
task.close()
|
||||
|
||||
def test_cancel(self):
|
||||
@ -1285,7 +1285,7 @@ class WrapperTaskTest(common.HeatTestCase):
|
||||
self.fail('parent_task not closed')
|
||||
|
||||
task = parent_task()
|
||||
task.next()
|
||||
next(task)
|
||||
task.close()
|
||||
|
||||
def test_cancel_exit(self):
|
||||
@ -1307,7 +1307,7 @@ class WrapperTaskTest(common.HeatTestCase):
|
||||
self.fail('parent_task not closed')
|
||||
|
||||
task = parent_task()
|
||||
task.next()
|
||||
next(task)
|
||||
task.close()
|
||||
|
||||
def test_cancel_parent_exit(self):
|
||||
@ -1329,5 +1329,5 @@ class WrapperTaskTest(common.HeatTestCase):
|
||||
self.fail('parent_task not closed')
|
||||
|
||||
task = parent_task()
|
||||
task.next()
|
||||
next(task)
|
||||
task.close()
|
||||
|
Loading…
Reference in New Issue
Block a user