py3: Miscellaneous fixes
* Use base64 from oslo_serialization
* Use six.BytesIO instead of StringIO
* Use sys.maxsize instead of sys.maxint
* Use sorted with a key argument to sort by
* Use range instead of moves.xrange or xrange
* Use floor division instead of float division
* Use 'r+' to open a file than 'rw'
* Use six.int2byte instead of chr
* Stop using conn.strict in response_class()
* Tests: Only compare length for bytes, not assertRegex
These changes are tested here: I3a1dfde76009cbac1d419e0ff3f1d20c4a2e99c3
Change-Id: Iab9c23e497956e45c5d04a3d6513acf1b026aafb
diff --git a/tempest/lib/common/utils/data_utils.py b/tempest/lib/common/utils/data_utils.py
index 6b6548e..70be40c 100644
--- a/tempest/lib/common/utils/data_utils.py
+++ b/tempest/lib/common/utils/data_utils.py
@@ -171,7 +171,7 @@
:return: size randomly bytes
:rtype: string
"""
- return ''.join([chr(random.randint(0, 255))
+ return b''.join([six.int2byte(random.randint(0, 255))
for i in range(size)])
@@ -204,5 +204,5 @@
# Courtesy of http://stackoverflow.com/a/312464
def chunkify(sequence, chunksize):
"""Yield successive chunks from `sequence`."""
- for i in six.moves.xrange(0, len(sequence), chunksize):
+ for i in range(0, len(sequence), chunksize):
yield sequence[i:i + chunksize]