py3: use six.moves.range instead of xrange
six is the canonical compatibility library for supporting Python 2 and 3 in a single codebase. The xrange module was removed in Python 3 and we should use 'six.moves.range' instead of 'xrange' to make code compatible with py 2 and 3 as well. Partially-implements blueprint py3-compatibility Change-Id: Id054857f320d9eda02bc0b82e5512c0595342290
This commit is contained in:
parent
67ccd12e42
commit
346b7c468a
@ -2,6 +2,7 @@
|
||||
# This is a hack of the builtin todo extension, to make the todo_list
|
||||
# more user friendly
|
||||
|
||||
from six import moves
|
||||
from sphinx.ext.todo import *
|
||||
import re
|
||||
|
||||
@ -25,7 +26,7 @@ def process_todo_nodes(app, doctree, fromdocname):
|
||||
# remove the item that was added in the constructor, since I'm tired of
|
||||
# reading through docutils for the proper way to construct an empty list
|
||||
lists = []
|
||||
for i in xrange(5):
|
||||
for i in moves.range(5):
|
||||
lists.append(nodes.bullet_list("", nodes.Text('', '')))
|
||||
lists[i].remove(lists[i][0])
|
||||
lists[i]['classes'].append('todo_list')
|
||||
|
@ -23,6 +23,7 @@ from xml.dom import minidom
|
||||
from lxml import etree
|
||||
from oslo.serialization import jsonutils
|
||||
import six
|
||||
from six import moves
|
||||
import webob
|
||||
|
||||
from manila.api.v1 import limits
|
||||
@ -407,7 +408,7 @@ class LimiterTest(BaseLimitTestSuite):
|
||||
|
||||
def _check(self, num, verb, url, username=None):
|
||||
"""Check and yield results from checks."""
|
||||
for x in xrange(num):
|
||||
for x in moves.range(num):
|
||||
yield self.limiter.check_for_delay(verb, url, username)[0]
|
||||
|
||||
def _check_sum(self, num, verb, url, username=None):
|
||||
|
@ -20,6 +20,7 @@ import datetime
|
||||
import mock
|
||||
from oslo.config import cfg
|
||||
from oslo.utils import timeutils
|
||||
from six import moves
|
||||
|
||||
from manila import db
|
||||
from manila import exception
|
||||
@ -48,7 +49,7 @@ class HostManagerTestCase(test.TestCase):
|
||||
super(HostManagerTestCase, self).setUp()
|
||||
self.host_manager = host_manager.HostManager()
|
||||
self.fake_hosts = [host_manager.HostState('fake_host%s' % x)
|
||||
for x in xrange(1, 5)]
|
||||
for x in moves.range(1, 5)]
|
||||
|
||||
def test_choose_host_filters_not_found(self):
|
||||
self.flags(scheduler_default_filters='FakeFilterClass3')
|
||||
@ -148,7 +149,7 @@ class HostManagerTestCase(test.TestCase):
|
||||
|
||||
self.assertEqual(4, len(host_state_map))
|
||||
# Check that service is up
|
||||
for i in xrange(4):
|
||||
for i in moves.range(4):
|
||||
share_node = fakes.SHARE_SERVICES[i]
|
||||
host = share_node['host']
|
||||
self.assertEqual(share_node, host_state_map[host].service)
|
||||
|
Loading…
Reference in New Issue
Block a user