python 3 compatibility: fix xrange/range issues
xrange is not defined in python3. Rename xrange() to range(). Change-Id: I6e2d934cee802fcd6fbca3d19c5d51a641fef018
This commit is contained in:
parent
8913695c00
commit
55052a2980
@ -101,7 +101,7 @@ class SBus(object):
|
||||
# Aggregate file descriptors
|
||||
n_files = pn_files.value
|
||||
h_files = []
|
||||
for i in xrange(n_files):
|
||||
for i in range(n_files):
|
||||
h_files.append(ph_files[i])
|
||||
|
||||
# Extract Python strings
|
||||
@ -142,7 +142,7 @@ class SBus(object):
|
||||
file_fds = datagram.fds
|
||||
h_files = (c_int * n_fds)()
|
||||
|
||||
for i in xrange(n_fds):
|
||||
for i in range(n_fds):
|
||||
h_files[i] = file_fds[i]
|
||||
|
||||
# Invoke C function
|
||||
|
@ -103,7 +103,7 @@ class TestPartitionsIdentityStorlet(StorletJavaFunctionalTest):
|
||||
# end=83,85,...,94 gets us deeper into the same line,
|
||||
# output should be the same:
|
||||
# lines 1-5, plus line 6 as the extra line
|
||||
for i in xrange(12):
|
||||
for i in range(12):
|
||||
content = self.invoke_storlet(12, i + 83, 'true', max_record_line)
|
||||
self.assertEqual(content, records_txt[12:95] + '\n')
|
||||
# Now that we move one extra character we get a different answer
|
||||
@ -118,18 +118,18 @@ class TestPartitionsIdentityStorlet(StorletJavaFunctionalTest):
|
||||
content = self.invoke_storlet(82, 185, 'false', max_record_line)
|
||||
self.assertEqual(content, records_txt[96:203] + '\n')
|
||||
# starting from 83 up to 95 should give the exact result
|
||||
for i in xrange(12):
|
||||
for i in range(12):
|
||||
content = self.invoke_storlet(i + 83, 185, 'false',
|
||||
max_record_line)
|
||||
self.assertEqual(content, records_txt[96:203] + '\n')
|
||||
# ending at any point up to 202 should give the exact result
|
||||
for i in xrange(16):
|
||||
for i in range(16):
|
||||
content = self.invoke_storlet(82, 186 + i, 'false',
|
||||
max_record_line)
|
||||
self.assertEqual(content, records_txt[96:203] + '\n')
|
||||
# now for the combinations of the two:
|
||||
for i in xrange(12):
|
||||
for j in xrange(16):
|
||||
for i in range(12):
|
||||
for j in range(16):
|
||||
content = self.invoke_storlet(83 + i, 186 + j, 'false',
|
||||
max_record_line)
|
||||
self.assertEqual(content, records_txt[96:203] + '\n')
|
||||
@ -138,7 +138,7 @@ class TestPartitionsIdentityStorlet(StorletJavaFunctionalTest):
|
||||
self._test_second_range(80)
|
||||
|
||||
def test_first_range(self):
|
||||
for max_record_line in xrange(5):
|
||||
for max_record_line in range(5):
|
||||
# The maximium line length in this section is 14
|
||||
# includuing the new line. and so any max length >=14
|
||||
# should be good.
|
||||
|
@ -41,7 +41,7 @@ class TestSLO(StorletPythonFunctionalTest):
|
||||
self.get_SLO()
|
||||
|
||||
def create_local_chunks(self):
|
||||
for i in xrange(9):
|
||||
for i in range(9):
|
||||
self.chunks.append(
|
||||
''.join([random.choice(string.ascii_uppercase + string.digits)
|
||||
for _ in range(1024 * 1024)]))
|
||||
@ -60,7 +60,7 @@ class TestSLO(StorletPythonFunctionalTest):
|
||||
|
||||
def put_SLO(self):
|
||||
assembly = []
|
||||
for i in xrange(9):
|
||||
for i in range(9):
|
||||
oname = 'slo_chunk_%d' % i
|
||||
content_length = None
|
||||
response = dict()
|
||||
@ -94,7 +94,7 @@ class TestSLO(StorletPythonFunctionalTest):
|
||||
def compare_slo_to_chunks(self, body):
|
||||
for (i, chunk) in enumerate(body):
|
||||
if chunk:
|
||||
if i in xrange(9):
|
||||
if i in range(9):
|
||||
self.assertEqual(chunk, self.chunks[i])
|
||||
else:
|
||||
aux_content = ''
|
||||
|
Loading…
x
Reference in New Issue
Block a user