Commit 269c886d authored by Jérome Perrin's avatar Jérome Perrin

py3: do not use xrange

parent c07ed743
......@@ -42,7 +42,7 @@ if getZopeVersion() < (4, ):
def getRandomString():
return "test.%s" %"".join([random.choice(string.ascii_letters + string.digits) for _ in xrange(32)])
return "test.%s" %"".join([random.choice(string.ascii_letters + string.digits) for _ in range(32)])
class TestDataIngestion(ERP5TypeTestCase):
......
......@@ -49,11 +49,11 @@ if getZopeVersion() < (4, ): # BBB Zope2
def getRandomString():
return 'test_%s' %''.join([random.choice(string.ascii_letters + string.digits) \
for _ in xrange(32)])
for _ in range(32)])
def chunks(l, n):
"""Yield successive n-sized chunks from l."""
for i in xrange(0, len(l), n):
for i in range(0, len(l), n):
yield l[i:i+n]
class Test(ERP5TypeTestCase):
......@@ -275,7 +275,7 @@ class Test(ERP5TypeTestCase):
bucket_stream.insertBucket(i, i*10000)
self.assertEqual(100, len(bucket_stream))
self.assertEqual(range(100), bucket_stream.getKeyList())
self.assertEqual(list(range(100)), bucket_stream.getKeyList())
# test as sequence
bucket = bucket_stream.getBucketKeyItemSequenceByKey(start_key=10, count=1)[0]
......
......@@ -34,7 +34,7 @@ class TestDataIngestion(SecurityTestCase):
self.assertEqual(self.PART_1, self.REFERENCE_SEPARATOR + self.portal.ERP5Site_getIngestionReferenceDictionary()["split_first_suffix"])
def getRandomReference(self):
random_string = ''.join([random.choice(string.ascii_letters + string.digits) for _ in xrange(10)])
random_string = ''.join([random.choice(string.ascii_letters + string.digits) for _ in range(10)])
return 'UNIT-TEST-' + random_string
def getIngestionReference(self, reference, extension, randomize_ingestion_reference=False, data_set_reference=False):
......@@ -58,7 +58,7 @@ class TestDataIngestion(SecurityTestCase):
return self.REF_SUPPLIER_PREFIX + ingestion_reference + self.REFERENCE_SEPARATOR + self.REFERENCE_SEPARATOR + str("") + self.REFERENCE_SEPARATOR + ""
def chunks(self, l, n):
for i in xrange(0, len(l), n):
for i in range(0, len(l), n):
yield l[i:i+n]
def getDataIngestion(self, reference):
......@@ -154,13 +154,13 @@ class TestDataIngestion(SecurityTestCase):
chunks).
"""
data_chunk_1 = ''.join([random.choice(string.ascii_letters + string.digits) \
for _ in xrange(250)])
for _ in range(250)])
data_chunk_2 = ''.join([random.choice(string.ascii_letters + string.digits) \
for _ in xrange(250)])
for _ in range(250)])
data_chunk_3 = ''.join([random.choice(string.ascii_letters + string.digits) \
for _ in xrange(250)])
for _ in range(250)])
data_chunk_4 = ''.join([random.choice(string.ascii_letters + string.digits) \
for _ in xrange(250)])
for _ in range(250)])
reference = self.getRandomReference()
......
......@@ -11,7 +11,7 @@ import string
def getRandomString():
return 'test_%s' %''.join([random.choice(string.ascii_letters + string.digits) \
for _ in xrange(32)])
for _ in range(32)])
# Game of Life examples
default_input_ndarray = np.array([[0,0,0,0,0,0],
......
import pandas as pd
import numpy as np
import re
from six.moves import range
import transaction
from DateTime import DateTime
from wendelin.bigarray.array_zodb import ZBigArray
......@@ -58,7 +59,7 @@ class ZBigArrayConverter(object):
data_array = result[0]
array = data_array.getArray()
for index in xrange(len(array)):
for index in range(len(array)):
# We need to order everything related to the data schema here. The Results methods
# `tuples()`, `names` and `data_dictionary` returns the fields in a different order
# and order is very important in the conversion to a ZBigArray. So we build
......@@ -179,7 +180,7 @@ class ZBigArrayExtender(object):
extension_dtype = DtypeIdentifier(self.extension).identify()
if not self.source.dtype == extension_dtype:
raise TypeError('Source and extension data types does not match.')
for index in xrange(len(self.extension)):
for index in range(len(self.extension)):
# Basically the same problem here with the order of Results instance fields
# when we convert it to an array.
ordered_movements = []
......
......@@ -18,7 +18,7 @@ if user_quantity is None:
"error_message": "Parameter 'user_quantity' is required.",
"password" : None })
password = ''.join(random.choice(string.digits + string.letters) for i in xrange(10))
password = ''.join(random.choice(string.digits + string.letters) for i in range(10))
# check erp5_scalability_test business template is present
configurator = portal.business_configuration_module.default_wendelin_configuration
......
......@@ -17,7 +17,7 @@ try:
organisation = organisation.getRelativeUrl()
for i in xrange(0, int(user_quantity)):
for i in range(0, int(user_quantity)):
user_id = "scalability_user_%i" % i
person = portal_catalog.getResultValue(
portal_type="Person",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment