Merge "py3: Use six module for StringIO imports"
This commit is contained in:
commit
28ccb31267
|
@ -12,9 +12,8 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import StringIO
|
||||
|
||||
from oslo.config import cfg
|
||||
import six
|
||||
import webob
|
||||
|
||||
from manila.api.middleware import sizelimit
|
||||
|
@ -30,14 +29,14 @@ class TestLimitingReader(test.TestCase):
|
|||
def test_limiting_reader(self):
|
||||
BYTES = 1024
|
||||
bytes_read = 0
|
||||
data = StringIO.StringIO("*" * BYTES)
|
||||
data = six.StringIO("*" * BYTES)
|
||||
for chunk in sizelimit.LimitingReader(data, BYTES):
|
||||
bytes_read += len(chunk)
|
||||
|
||||
self.assertEqual(bytes_read, BYTES)
|
||||
|
||||
bytes_read = 0
|
||||
data = StringIO.StringIO("*" * BYTES)
|
||||
data = six.StringIO("*" * BYTES)
|
||||
reader = sizelimit.LimitingReader(data, BYTES)
|
||||
byte = reader.read(1)
|
||||
while len(byte) != 0:
|
||||
|
@ -51,7 +50,7 @@ class TestLimitingReader(test.TestCase):
|
|||
|
||||
def _consume_all_iter():
|
||||
bytes_read = 0
|
||||
data = StringIO.StringIO("*" * BYTES)
|
||||
data = six.StringIO("*" * BYTES)
|
||||
for chunk in sizelimit.LimitingReader(data, BYTES - 1):
|
||||
bytes_read += len(chunk)
|
||||
|
||||
|
@ -60,7 +59,7 @@ class TestLimitingReader(test.TestCase):
|
|||
|
||||
def _consume_all_read():
|
||||
bytes_read = 0
|
||||
data = StringIO.StringIO("*" * BYTES)
|
||||
data = six.StringIO("*" * BYTES)
|
||||
reader = sizelimit.LimitingReader(data, BYTES - 1)
|
||||
byte = reader.read(1)
|
||||
while len(byte) != 0:
|
||||
|
|
|
@ -18,10 +18,10 @@ Tests dealing with HTTP rate-limiting.
|
|||
"""
|
||||
|
||||
import httplib
|
||||
import StringIO
|
||||
from xml.dom import minidom
|
||||
|
||||
from lxml import etree
|
||||
import six
|
||||
import webob
|
||||
|
||||
from manila.api.v1 import limits
|
||||
|
@ -622,7 +622,7 @@ class FakeHttplibSocket(object):
|
|||
|
||||
def __init__(self, response_string):
|
||||
"""Initialize new `FakeHttplibSocket`."""
|
||||
self._buffer = StringIO.StringIO(response_string)
|
||||
self._buffer = six.StringIO(response_string)
|
||||
|
||||
def makefile(self, _mode, _other):
|
||||
"""Returns the socket's internal buffer."""
|
||||
|
|
|
@ -17,7 +17,8 @@ Tests For PickledScheduler.
|
|||
"""
|
||||
|
||||
import datetime
|
||||
import StringIO
|
||||
|
||||
import six
|
||||
|
||||
from manila.openstack.common import jsonutils
|
||||
from manila.scheduler import scheduler_options
|
||||
|
@ -44,7 +45,7 @@ class FakeSchedulerOptions(scheduler_options.SchedulerOptions):
|
|||
|
||||
def _get_file_handle(self, filename):
|
||||
self.file_was_loaded = True
|
||||
return StringIO.StringIO(self._file_data)
|
||||
return six.StringIO(self._file_data)
|
||||
|
||||
def _get_time_now(self):
|
||||
return self._time_now
|
||||
|
|
|
@ -19,8 +19,8 @@
|
|||
"""Unit tests for the API endpoint."""
|
||||
|
||||
import httplib
|
||||
import StringIO
|
||||
|
||||
import six
|
||||
import webob
|
||||
|
||||
|
||||
|
@ -28,7 +28,7 @@ class FakeHttplibSocket(object):
|
|||
"""A fake socket implementation for httplib.HTTPResponse, trivial."""
|
||||
def __init__(self, response_string):
|
||||
self.response_string = response_string
|
||||
self._buffer = StringIO.StringIO(response_string)
|
||||
self._buffer = six.StringIO(response_string)
|
||||
|
||||
def makefile(self, _mode, _other):
|
||||
"""Returns the socket's internal buffer."""
|
||||
|
|
|
@ -21,13 +21,13 @@ import hashlib
|
|||
import os
|
||||
import os.path
|
||||
import socket
|
||||
import StringIO
|
||||
import tempfile
|
||||
import uuid
|
||||
|
||||
import mock
|
||||
from oslo.config import cfg
|
||||
import paramiko
|
||||
import six
|
||||
|
||||
import manila
|
||||
from manila import exception
|
||||
|
@ -358,7 +358,7 @@ class GenericUtilsTestCase(test.TestCase):
|
|||
|
||||
def test_hash_file(self):
|
||||
data = 'Mary had a little lamb, its fleece as white as snow'
|
||||
flo = StringIO.StringIO(data)
|
||||
flo = six.StringIO(data)
|
||||
h1 = utils.hash_file(flo)
|
||||
h2 = hashlib.sha1(data).hexdigest()
|
||||
self.assertEqual(h1, h2)
|
||||
|
|
Loading…
Reference in New Issue