Merge "Get StringIO and cStringIO from six.moves"
This commit is contained in:
commit
260e976e50
@ -16,13 +16,13 @@
|
||||
|
||||
import traceback
|
||||
from ConfigParser import ConfigParser
|
||||
from cStringIO import StringIO
|
||||
from optparse import OptionParser
|
||||
from sys import exit, stdout
|
||||
from time import time
|
||||
from six.moves import range
|
||||
from eventlet import GreenPool, patcher, sleep
|
||||
from eventlet.pools import Pool
|
||||
from six.moves import cStringIO as StringIO
|
||||
|
||||
try:
|
||||
from swiftclient import get_auth
|
||||
|
@ -147,8 +147,8 @@ metadata which can be used for stats purposes.
|
||||
"""
|
||||
|
||||
from six.moves import range
|
||||
from six.moves import cStringIO as StringIO
|
||||
|
||||
from cStringIO import StringIO
|
||||
from datetime import datetime
|
||||
import mimetypes
|
||||
import re
|
||||
|
@ -36,7 +36,6 @@ needs to change.
|
||||
"""
|
||||
|
||||
from collections import defaultdict
|
||||
from StringIO import StringIO
|
||||
import UserDict
|
||||
import time
|
||||
from functools import partial
|
||||
@ -49,6 +48,8 @@ import random
|
||||
import functools
|
||||
import inspect
|
||||
|
||||
from six import StringIO
|
||||
|
||||
from swift.common.utils import reiterate, split_path, Timestamp, pairs, \
|
||||
close_if_possible
|
||||
from swift.common.exceptions import InvalidTimestamp
|
||||
|
@ -24,7 +24,6 @@ import signal
|
||||
import time
|
||||
import mimetools
|
||||
from swift import gettext_ as _
|
||||
from StringIO import StringIO
|
||||
from textwrap import dedent
|
||||
|
||||
import eventlet
|
||||
@ -32,6 +31,7 @@ import eventlet.debug
|
||||
from eventlet import greenio, GreenPool, sleep, wsgi, listen, Timeout
|
||||
from paste.deploy import loadwsgi
|
||||
from eventlet.green import socket, ssl, os as green_os
|
||||
from six import StringIO
|
||||
from urllib import unquote
|
||||
|
||||
from swift.common import utils, constraints
|
||||
|
@ -15,12 +15,12 @@
|
||||
|
||||
""" In-Memory Disk File Interface for Swift Object Server"""
|
||||
|
||||
import cStringIO
|
||||
import time
|
||||
import hashlib
|
||||
from contextlib import contextmanager
|
||||
|
||||
from eventlet import Timeout
|
||||
from six import moves
|
||||
|
||||
from swift.common.utils import Timestamp
|
||||
from swift.common.exceptions import DiskFileQuarantined, DiskFileNotExist, \
|
||||
@ -385,7 +385,7 @@ class DiskFile(object):
|
||||
disk
|
||||
:raises DiskFileNoSpace: if a size is specified and allocation fails
|
||||
"""
|
||||
fp = cStringIO.StringIO()
|
||||
fp = moves.cStringIO()
|
||||
try:
|
||||
yield DiskFileWriter(self._filesystem, self._name, fp)
|
||||
finally:
|
||||
|
@ -18,7 +18,6 @@ import httplib
|
||||
import os
|
||||
import random
|
||||
import socket
|
||||
import StringIO
|
||||
import time
|
||||
import urllib
|
||||
|
||||
@ -27,6 +26,7 @@ import simplejson as json
|
||||
from nose import SkipTest
|
||||
from xml.dom import minidom
|
||||
|
||||
import six
|
||||
from swiftclient import get_auth
|
||||
|
||||
from swift.common import constraints
|
||||
@ -655,7 +655,7 @@ class File(Base):
|
||||
block_size = 4096
|
||||
|
||||
if isinstance(data, str):
|
||||
data = StringIO.StringIO(data)
|
||||
data = six.StringIO(data)
|
||||
|
||||
checksum = hashlib.md5()
|
||||
buff = data.read(block_size)
|
||||
@ -930,7 +930,7 @@ class File(Base):
|
||||
pass
|
||||
self.size = int(os.fstat(data.fileno())[6])
|
||||
else:
|
||||
data = StringIO.StringIO(data)
|
||||
data = six.StringIO(data)
|
||||
self.size = data.len
|
||||
|
||||
headers = self.make_headers(cfg=cfg)
|
||||
@ -982,7 +982,7 @@ class File(Base):
|
||||
if not self.write(data, hdrs=hdrs, parms=parms, cfg=cfg):
|
||||
raise ResponseError(self.conn.response, 'PUT',
|
||||
self.conn.make_path(self.path))
|
||||
self.md5 = self.compute_md5sum(StringIO.StringIO(data))
|
||||
self.md5 = self.compute_md5sum(six.StringIO(data))
|
||||
return data
|
||||
|
||||
def write_random_return_resp(self, size=None, hdrs=None, parms=None,
|
||||
@ -999,5 +999,5 @@ class File(Base):
|
||||
return_resp=True)
|
||||
if not resp:
|
||||
raise ResponseError(self.conn.response)
|
||||
self.md5 = self.compute_md5sum(StringIO.StringIO(data))
|
||||
self.md5 = self.compute_md5sum(six.StringIO(data))
|
||||
return resp
|
||||
|
@ -20,7 +20,7 @@ import hmac
|
||||
import json
|
||||
import locale
|
||||
import random
|
||||
import StringIO
|
||||
import six
|
||||
import time
|
||||
import unittest
|
||||
import urllib
|
||||
@ -1730,7 +1730,7 @@ class TestFile(Base):
|
||||
def testEtagResponse(self):
|
||||
file_item = self.env.container.file(Utils.create_name())
|
||||
|
||||
data = StringIO.StringIO(file_item.write_random(512))
|
||||
data = six.StringIO(file_item.write_random(512))
|
||||
etag = File.compute_md5sum(data)
|
||||
|
||||
headers = dict(self.env.conn.response.getheaders())
|
||||
|
@ -19,13 +19,13 @@ import mock
|
||||
import unittest
|
||||
from tempfile import mkdtemp
|
||||
from shutil import rmtree
|
||||
from StringIO import StringIO
|
||||
from time import gmtime
|
||||
from test.unit import FakeLogger
|
||||
import itertools
|
||||
import random
|
||||
|
||||
import simplejson
|
||||
from six import StringIO
|
||||
import xml.dom.minidom
|
||||
|
||||
from swift import __version__ as swift_version
|
||||
|
@ -17,8 +17,8 @@
|
||||
import hashlib
|
||||
import hmac
|
||||
import mock
|
||||
from six import StringIO
|
||||
import unittest
|
||||
from StringIO import StringIO
|
||||
|
||||
from swift.cli import form_signature
|
||||
|
||||
|
@ -15,10 +15,10 @@
|
||||
import os
|
||||
import unittest
|
||||
import mock
|
||||
from cStringIO import StringIO
|
||||
from shutil import rmtree
|
||||
from tempfile import mkdtemp
|
||||
|
||||
from six.moves import cStringIO as StringIO
|
||||
from test.unit import patch_policies, write_fake_ring
|
||||
|
||||
from swift.common import ring, utils
|
||||
|
@ -20,13 +20,13 @@ import os
|
||||
import random
|
||||
import re
|
||||
import string
|
||||
from StringIO import StringIO
|
||||
import tempfile
|
||||
import time
|
||||
import unittest
|
||||
import urlparse
|
||||
|
||||
from eventlet.green import urllib2
|
||||
from six import StringIO
|
||||
|
||||
from swift.cli import recon
|
||||
from swift.common import utils
|
||||
|
@ -16,7 +16,7 @@
|
||||
import logging
|
||||
import mock
|
||||
import os
|
||||
import StringIO
|
||||
import six
|
||||
import tempfile
|
||||
import unittest
|
||||
import uuid
|
||||
@ -29,8 +29,8 @@ from swift.common.ring import RingBuilder
|
||||
class RunSwiftRingBuilderMixin(object):
|
||||
|
||||
def run_srb(self, *argv):
|
||||
mock_stdout = StringIO.StringIO()
|
||||
mock_stderr = StringIO.StringIO()
|
||||
mock_stdout = six.StringIO()
|
||||
mock_stderr = six.StringIO()
|
||||
|
||||
srb_args = ["", self.tempfile] + [str(s) for s in argv]
|
||||
|
||||
@ -1756,8 +1756,8 @@ class TestRebalanceCommand(unittest.TestCase, RunSwiftRingBuilderMixin):
|
||||
pass
|
||||
|
||||
def run_srb(self, *argv):
|
||||
mock_stdout = StringIO.StringIO()
|
||||
mock_stderr = StringIO.StringIO()
|
||||
mock_stdout = six.StringIO()
|
||||
mock_stderr = six.StringIO()
|
||||
|
||||
srb_args = ["", self.tempfile] + [str(s) for s in argv]
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
# limitations under the License.
|
||||
|
||||
import numbers
|
||||
from six import StringIO
|
||||
import unittest
|
||||
import os
|
||||
import tarfile
|
||||
@ -23,7 +24,6 @@ import zlib
|
||||
import mock
|
||||
from shutil import rmtree
|
||||
from tempfile import mkdtemp
|
||||
from StringIO import StringIO
|
||||
from eventlet import sleep
|
||||
from mock import patch, call
|
||||
from test.unit.common.middleware.helpers import FakeSwift
|
||||
|
@ -16,9 +16,10 @@
|
||||
import hmac
|
||||
import unittest
|
||||
from hashlib import sha1
|
||||
from StringIO import StringIO
|
||||
from time import time
|
||||
|
||||
from six import StringIO
|
||||
|
||||
from swift.common.swob import Request, Response
|
||||
from swift.common.middleware import tempauth, formpost
|
||||
from swift.common.utils import split_path
|
||||
|
@ -13,9 +13,9 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from six import moves
|
||||
import unittest
|
||||
from urllib import unquote
|
||||
import cStringIO as StringIO
|
||||
from logging.handlers import SysLogHandler
|
||||
import mock
|
||||
|
||||
@ -194,7 +194,7 @@ class TestProxyLogging(unittest.TestCase):
|
||||
app.access_logger = FakeLogger()
|
||||
req = Request.blank(path, environ={
|
||||
'REQUEST_METHOD': 'GET',
|
||||
'wsgi.input': StringIO.StringIO('4321')})
|
||||
'wsgi.input': moves.cStringIO('4321')})
|
||||
stub_times = [18.0, 20.71828182846]
|
||||
iter_response = app(req.environ, lambda *_: None)
|
||||
self.assertEqual('7654321', ''.join(iter_response))
|
||||
@ -213,7 +213,7 @@ class TestProxyLogging(unittest.TestCase):
|
||||
req = Request.blank(path, environ={
|
||||
'REQUEST_METHOD': 'GET',
|
||||
'swift.proxy_access_log_made': True,
|
||||
'wsgi.input': StringIO.StringIO('4321')})
|
||||
'wsgi.input': moves.cStringIO('4321')})
|
||||
stub_times = [18.0, 20.71828182846]
|
||||
iter_response = app(req.environ, lambda *_: None)
|
||||
self.assertEqual('7654321', ''.join(iter_response))
|
||||
@ -229,7 +229,7 @@ class TestProxyLogging(unittest.TestCase):
|
||||
app.access_logger = FakeLogger()
|
||||
req = Request.blank(path, environ={
|
||||
'REQUEST_METHOD': 'PUT',
|
||||
'wsgi.input': StringIO.StringIO('654321')})
|
||||
'wsgi.input': moves.cStringIO('654321')})
|
||||
# (it's not a GET, so time() doesn't have a 2nd call)
|
||||
stub_times = [58.2, 58.2 + 7.3321]
|
||||
iter_response = app(req.environ, lambda *_: None)
|
||||
@ -377,7 +377,7 @@ class TestProxyLogging(unittest.TestCase):
|
||||
req = Request.blank(
|
||||
'/v1/a/c/o/foo',
|
||||
environ={'REQUEST_METHOD': 'PUT',
|
||||
'wsgi.input': StringIO.StringIO('some stuff')})
|
||||
'wsgi.input': moves.cStringIO('some stuff')})
|
||||
resp = app(req.environ, start_response)
|
||||
# exhaust generator
|
||||
[x for x in resp]
|
||||
@ -395,7 +395,7 @@ class TestProxyLogging(unittest.TestCase):
|
||||
req = Request.blank(
|
||||
'/v1/a/c',
|
||||
environ={'REQUEST_METHOD': 'POST',
|
||||
'wsgi.input': StringIO.StringIO(
|
||||
'wsgi.input': moves.cStringIO(
|
||||
'some stuff\nsome other stuff\n')})
|
||||
resp = app(req.environ, start_response)
|
||||
# exhaust generator
|
||||
|
@ -16,11 +16,12 @@
|
||||
import os
|
||||
import json
|
||||
import shutil
|
||||
import StringIO
|
||||
import tempfile
|
||||
import unittest
|
||||
from nose import SkipTest
|
||||
|
||||
import six
|
||||
|
||||
from swift import gettext_ as _
|
||||
from swift.common.swob import Request, Response
|
||||
|
||||
@ -111,7 +112,7 @@ class TestProfileMiddleware(unittest.TestCase):
|
||||
def test_combine_body_qs(self):
|
||||
body = "profile=all&sort=time&limit=-1&fulldirs=1&nfl_filter=__call__"\
|
||||
+ "&query=query&metric=nc&format=default"
|
||||
wsgi_input = StringIO.StringIO(body)
|
||||
wsgi_input = six.StringIO(body)
|
||||
environ = {'REQUEST_METHOD': 'GET',
|
||||
'QUERY_STRING': 'profile=all&format=json',
|
||||
'wsgi.input': wsgi_input}
|
||||
@ -129,7 +130,7 @@ class TestProfileMiddleware(unittest.TestCase):
|
||||
def test_call(self):
|
||||
body = "sort=time&limit=-1&fulldirs=1&nfl_filter="\
|
||||
+ "&metric=nc"
|
||||
wsgi_input = StringIO.StringIO(body + '&query=query')
|
||||
wsgi_input = six.StringIO(body + '&query=query')
|
||||
environ = {'HTTP_HOST': 'localhost:8080',
|
||||
'PATH_INFO': '/__profile__',
|
||||
'REQUEST_METHOD': 'GET',
|
||||
@ -139,7 +140,7 @@ class TestProfileMiddleware(unittest.TestCase):
|
||||
self.assertTrue(resp[0].find('<html>') > 0, resp)
|
||||
self.assertEqual(self.got_statuses, ['200 OK'])
|
||||
self.assertEqual(self.headers, [('content-type', 'text/html')])
|
||||
wsgi_input = StringIO.StringIO(body + '&plot=plot')
|
||||
wsgi_input = six.StringIO(body + '&plot=plot')
|
||||
environ['wsgi.input'] = wsgi_input
|
||||
if PLOTLIB_INSTALLED:
|
||||
resp = self.app(environ, self.start_response)
|
||||
@ -148,13 +149,12 @@ class TestProfileMiddleware(unittest.TestCase):
|
||||
else:
|
||||
resp = self.app(environ, self.start_response)
|
||||
self.assertEqual(self.got_statuses, ['500 Internal Server Error'])
|
||||
wsgi_input = StringIO.StringIO(body +
|
||||
'&download=download&format=default')
|
||||
wsgi_input = six.StringIO(body + '&download=download&format=default')
|
||||
environ['wsgi.input'] = wsgi_input
|
||||
resp = self.app(environ, self.start_response)
|
||||
self.assertEqual(self.headers, [('content-type',
|
||||
HTMLViewer.format_dict['default'])])
|
||||
wsgi_input = StringIO.StringIO(body + '&download=download&format=json')
|
||||
wsgi_input = six.StringIO(body + '&download=download&format=json')
|
||||
environ['wsgi.input'] = wsgi_input
|
||||
resp = self.app(environ, self.start_response)
|
||||
self.assertTrue(self.headers == [('content-type',
|
||||
@ -165,12 +165,12 @@ class TestProfileMiddleware(unittest.TestCase):
|
||||
self.assertEqual(self.got_statuses, ['405 Method Not Allowed'], resp)
|
||||
|
||||
# use a totally bogus profile identifier
|
||||
wsgi_input = StringIO.StringIO(body + '&profile=ABC&download=download')
|
||||
wsgi_input = six.StringIO(body + '&profile=ABC&download=download')
|
||||
environ['wsgi.input'] = wsgi_input
|
||||
resp = self.app(environ, self.start_response)
|
||||
self.assertEqual(self.got_statuses, ['404 Not Found'], resp)
|
||||
|
||||
wsgi_input = StringIO.StringIO(body + '&download=download&format=ods')
|
||||
wsgi_input = six.StringIO(body + '&download=download&format=ods')
|
||||
environ['wsgi.input'] = wsgi_input
|
||||
resp = self.app(environ, self.start_response)
|
||||
if ODFLIB_INSTALLED:
|
||||
@ -300,7 +300,7 @@ class Test_html_viewer(unittest.TestCase):
|
||||
self.profile_log)
|
||||
body = "profile=123&profile=456&sort=time&sort=nc&limit=10"\
|
||||
+ "&fulldirs=1&nfl_filter=getcwd&query=query&metric=nc"
|
||||
wsgi_input = StringIO.StringIO(body)
|
||||
wsgi_input = six.StringIO(body)
|
||||
environ = {'REQUEST_METHOD': 'GET',
|
||||
'QUERY_STRING': 'profile=all',
|
||||
'wsgi.input': wsgi_input}
|
||||
|
@ -16,10 +16,10 @@
|
||||
# TODO(clayg): Test kill_children signal handlers
|
||||
|
||||
import os
|
||||
from six import StringIO
|
||||
import unittest
|
||||
from getpass import getuser
|
||||
import logging
|
||||
from StringIO import StringIO
|
||||
from test.unit import tmpfile
|
||||
from mock import patch
|
||||
|
||||
|
@ -18,11 +18,11 @@ import unittest
|
||||
import os
|
||||
import urllib
|
||||
from contextlib import contextmanager
|
||||
import StringIO
|
||||
from hashlib import md5
|
||||
import time
|
||||
|
||||
import mock
|
||||
import six
|
||||
|
||||
from swift.common import direct_client
|
||||
from swift.common.exceptions import ClientException
|
||||
@ -481,7 +481,7 @@ class TestDirectClient(unittest.TestCase):
|
||||
important_timestamp)
|
||||
|
||||
def test_direct_get_object(self):
|
||||
contents = StringIO.StringIO('123456')
|
||||
contents = six.StringIO('123456')
|
||||
|
||||
with mocked_http_conn(200, body=contents) as conn:
|
||||
resp_header, obj_body = direct_client.direct_get_object(
|
||||
@ -580,7 +580,7 @@ class TestDirectClient(unittest.TestCase):
|
||||
self.assertTrue('DELETE' in str(err))
|
||||
|
||||
def test_direct_put_object_with_content_length(self):
|
||||
contents = StringIO.StringIO('123456')
|
||||
contents = six.StringIO('123456')
|
||||
|
||||
with mocked_http_conn(200) as conn:
|
||||
resp = direct_client.direct_put_object(
|
||||
@ -591,7 +591,7 @@ class TestDirectClient(unittest.TestCase):
|
||||
self.assertEqual(md5('123456').hexdigest(), resp)
|
||||
|
||||
def test_direct_put_object_fail(self):
|
||||
contents = StringIO.StringIO('123456')
|
||||
contents = six.StringIO('123456')
|
||||
|
||||
with mocked_http_conn(500) as conn:
|
||||
try:
|
||||
@ -607,7 +607,7 @@ class TestDirectClient(unittest.TestCase):
|
||||
self.assertEqual(err.http_status, 500)
|
||||
|
||||
def test_direct_put_object_chunked(self):
|
||||
contents = StringIO.StringIO('123456')
|
||||
contents = six.StringIO('123456')
|
||||
|
||||
with mocked_http_conn(200) as conn:
|
||||
resp = direct_client.direct_put_object(
|
||||
|
@ -15,7 +15,6 @@
|
||||
|
||||
import json
|
||||
import mock
|
||||
from StringIO import StringIO
|
||||
import unittest
|
||||
from urllib import quote
|
||||
import zlib
|
||||
@ -23,6 +22,7 @@ from textwrap import dedent
|
||||
import os
|
||||
|
||||
import six
|
||||
from six import StringIO
|
||||
from six.moves import range
|
||||
from test.unit import FakeLogger
|
||||
import eventlet
|
||||
|
@ -12,8 +12,8 @@
|
||||
# limitations under the License.
|
||||
|
||||
""" Tests for swift.common.storage_policies """
|
||||
import six
|
||||
import unittest
|
||||
import StringIO
|
||||
from ConfigParser import ConfigParser
|
||||
import os
|
||||
import mock
|
||||
@ -46,7 +46,7 @@ class TestStoragePolicies(unittest.TestCase):
|
||||
def _conf(self, conf_str):
|
||||
conf_str = "\n".join(line.strip() for line in conf_str.split("\n"))
|
||||
conf = ConfigParser()
|
||||
conf.readfp(StringIO.StringIO(conf_str))
|
||||
conf.readfp(six.StringIO(conf_str))
|
||||
return conf
|
||||
|
||||
def assertRaisesWithMessage(self, exc_class, message, f, *args, **kwargs):
|
||||
|
@ -19,9 +19,10 @@ import datetime
|
||||
import unittest
|
||||
import re
|
||||
import time
|
||||
from StringIO import StringIO
|
||||
from urllib import quote
|
||||
|
||||
from six import StringIO
|
||||
|
||||
import swift.common.swob
|
||||
from swift.common import utils, exceptions
|
||||
|
||||
|
@ -28,6 +28,7 @@ import os
|
||||
import mock
|
||||
import random
|
||||
import re
|
||||
from six import StringIO
|
||||
from six.moves import range
|
||||
import socket
|
||||
import stat
|
||||
@ -49,7 +50,6 @@ from contextlib import nested
|
||||
from Queue import Queue, Empty
|
||||
from getpass import getuser
|
||||
from shutil import rmtree
|
||||
from StringIO import StringIO
|
||||
from functools import partial
|
||||
from tempfile import TemporaryFile, NamedTemporaryFile, mkdtemp
|
||||
from netifaces import AF_INET6
|
||||
|
@ -23,11 +23,11 @@ import unittest
|
||||
import os
|
||||
from textwrap import dedent
|
||||
from contextlib import nested
|
||||
from StringIO import StringIO
|
||||
from collections import defaultdict
|
||||
from urllib import quote
|
||||
|
||||
from eventlet import listen
|
||||
from six import StringIO
|
||||
|
||||
import mock
|
||||
|
||||
|
@ -16,11 +16,11 @@
|
||||
import operator
|
||||
import os
|
||||
import mock
|
||||
from six import StringIO
|
||||
import unittest
|
||||
import itertools
|
||||
from contextlib import contextmanager
|
||||
from shutil import rmtree
|
||||
from StringIO import StringIO
|
||||
from tempfile import mkdtemp
|
||||
from test.unit import FakeLogger
|
||||
from time import gmtime
|
||||
|
@ -23,11 +23,11 @@ import errno
|
||||
import operator
|
||||
import os
|
||||
import mock
|
||||
from six import StringIO
|
||||
import unittest
|
||||
import math
|
||||
import random
|
||||
from shutil import rmtree
|
||||
from StringIO import StringIO
|
||||
from time import gmtime, strftime, time, struct_time
|
||||
from tempfile import mkdtemp
|
||||
from hashlib import md5
|
||||
|
@ -16,12 +16,12 @@
|
||||
import contextlib
|
||||
import os
|
||||
import shutil
|
||||
import StringIO
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
import eventlet
|
||||
import mock
|
||||
import six
|
||||
|
||||
from swift.common import bufferedhttp
|
||||
from swift.common import exceptions
|
||||
@ -408,10 +408,10 @@ class TestReceiver(unittest.TestCase):
|
||||
|
||||
def test_SSYNC_Exception(self):
|
||||
|
||||
class _Wrapper(StringIO.StringIO):
|
||||
class _Wrapper(six.StringIO):
|
||||
|
||||
def __init__(self, value):
|
||||
StringIO.StringIO.__init__(self, value)
|
||||
six.StringIO.__init__(self, value)
|
||||
self.mock_socket = mock.MagicMock()
|
||||
|
||||
def get_socket(self):
|
||||
@ -443,10 +443,10 @@ class TestReceiver(unittest.TestCase):
|
||||
|
||||
def test_SSYNC_Exception_Exception(self):
|
||||
|
||||
class _Wrapper(StringIO.StringIO):
|
||||
class _Wrapper(six.StringIO):
|
||||
|
||||
def __init__(self, value):
|
||||
StringIO.StringIO.__init__(self, value)
|
||||
six.StringIO.__init__(self, value)
|
||||
self.mock_socket = mock.MagicMock()
|
||||
|
||||
def get_socket(self):
|
||||
@ -479,14 +479,14 @@ class TestReceiver(unittest.TestCase):
|
||||
|
||||
def test_MISSING_CHECK_timeout(self):
|
||||
|
||||
class _Wrapper(StringIO.StringIO):
|
||||
class _Wrapper(six.StringIO):
|
||||
|
||||
def __init__(self, value):
|
||||
StringIO.StringIO.__init__(self, value)
|
||||
six.StringIO.__init__(self, value)
|
||||
self.mock_socket = mock.MagicMock()
|
||||
|
||||
def readline(self, sizehint=-1):
|
||||
line = StringIO.StringIO.readline(self)
|
||||
line = six.StringIO.readline(self)
|
||||
if line.startswith('hash'):
|
||||
eventlet.sleep(0.1)
|
||||
return line
|
||||
@ -521,14 +521,14 @@ class TestReceiver(unittest.TestCase):
|
||||
|
||||
def test_MISSING_CHECK_other_exception(self):
|
||||
|
||||
class _Wrapper(StringIO.StringIO):
|
||||
class _Wrapper(six.StringIO):
|
||||
|
||||
def __init__(self, value):
|
||||
StringIO.StringIO.__init__(self, value)
|
||||
six.StringIO.__init__(self, value)
|
||||
self.mock_socket = mock.MagicMock()
|
||||
|
||||
def readline(self, sizehint=-1):
|
||||
line = StringIO.StringIO.readline(self)
|
||||
line = six.StringIO.readline(self)
|
||||
if line.startswith('hash'):
|
||||
raise Exception('test exception')
|
||||
return line
|
||||
@ -766,14 +766,14 @@ class TestReceiver(unittest.TestCase):
|
||||
|
||||
def test_UPDATES_timeout(self):
|
||||
|
||||
class _Wrapper(StringIO.StringIO):
|
||||
class _Wrapper(six.StringIO):
|
||||
|
||||
def __init__(self, value):
|
||||
StringIO.StringIO.__init__(self, value)
|
||||
six.StringIO.__init__(self, value)
|
||||
self.mock_socket = mock.MagicMock()
|
||||
|
||||
def readline(self, sizehint=-1):
|
||||
line = StringIO.StringIO.readline(self)
|
||||
line = six.StringIO.readline(self)
|
||||
if line.startswith('DELETE'):
|
||||
eventlet.sleep(0.1)
|
||||
return line
|
||||
@ -813,14 +813,14 @@ class TestReceiver(unittest.TestCase):
|
||||
|
||||
def test_UPDATES_other_exception(self):
|
||||
|
||||
class _Wrapper(StringIO.StringIO):
|
||||
class _Wrapper(six.StringIO):
|
||||
|
||||
def __init__(self, value):
|
||||
StringIO.StringIO.__init__(self, value)
|
||||
six.StringIO.__init__(self, value)
|
||||
self.mock_socket = mock.MagicMock()
|
||||
|
||||
def readline(self, sizehint=-1):
|
||||
line = StringIO.StringIO.readline(self)
|
||||
line = six.StringIO.readline(self)
|
||||
if line.startswith('DELETE'):
|
||||
raise Exception('test exception')
|
||||
return line
|
||||
@ -859,10 +859,10 @@ class TestReceiver(unittest.TestCase):
|
||||
|
||||
def test_UPDATES_no_problems_no_hard_disconnect(self):
|
||||
|
||||
class _Wrapper(StringIO.StringIO):
|
||||
class _Wrapper(six.StringIO):
|
||||
|
||||
def __init__(self, value):
|
||||
StringIO.StringIO.__init__(self, value)
|
||||
six.StringIO.__init__(self, value)
|
||||
self.mock_socket = mock.MagicMock()
|
||||
|
||||
def get_socket(self):
|
||||
@ -1547,13 +1547,13 @@ class TestReceiver(unittest.TestCase):
|
||||
request.read_body = request.environ['wsgi.input'].read(2)
|
||||
return swob.HTTPInternalServerError()
|
||||
|
||||
class _IgnoreReadlineHint(StringIO.StringIO):
|
||||
class _IgnoreReadlineHint(six.StringIO):
|
||||
|
||||
def __init__(self, value):
|
||||
StringIO.StringIO.__init__(self, value)
|
||||
six.StringIO.__init__(self, value)
|
||||
|
||||
def readline(self, hint=-1):
|
||||
return StringIO.StringIO.readline(self)
|
||||
return six.StringIO.readline(self)
|
||||
|
||||
self.controller.PUT = _PUT
|
||||
self.controller.network_chunk_size = 2
|
||||
|
@ -16,7 +16,6 @@
|
||||
import hashlib
|
||||
import os
|
||||
import shutil
|
||||
import StringIO
|
||||
import tempfile
|
||||
import time
|
||||
import unittest
|
||||
@ -24,6 +23,7 @@ import unittest
|
||||
import eventlet
|
||||
import itertools
|
||||
import mock
|
||||
import six
|
||||
|
||||
from swift.common import exceptions, utils
|
||||
from swift.common.storage_policy import POLICIES
|
||||
@ -77,7 +77,7 @@ class FakeResponse(object):
|
||||
self.status = 200
|
||||
self.close_called = False
|
||||
if chunk_body:
|
||||
self.fp = StringIO.StringIO(
|
||||
self.fp = six.StringIO(
|
||||
'%x\r\n%s\r\n0\r\n\r\n' % (len(chunk_body), chunk_body))
|
||||
|
||||
def read(self, *args, **kwargs):
|
||||
@ -607,39 +607,39 @@ class TestSender(BaseTestSender):
|
||||
|
||||
def test_readline_at_start_of_chunk(self):
|
||||
self.sender.response = FakeResponse()
|
||||
self.sender.response.fp = StringIO.StringIO('2\r\nx\n\r\n')
|
||||
self.sender.response.fp = six.StringIO('2\r\nx\n\r\n')
|
||||
self.assertEqual(self.sender.readline(), 'x\n')
|
||||
|
||||
def test_readline_chunk_with_extension(self):
|
||||
self.sender.response = FakeResponse()
|
||||
self.sender.response.fp = StringIO.StringIO(
|
||||
self.sender.response.fp = six.StringIO(
|
||||
'2 ; chunk=extension\r\nx\n\r\n')
|
||||
self.assertEqual(self.sender.readline(), 'x\n')
|
||||
|
||||
def test_readline_broken_chunk(self):
|
||||
self.sender.response = FakeResponse()
|
||||
self.sender.response.fp = StringIO.StringIO('q\r\nx\n\r\n')
|
||||
self.sender.response.fp = six.StringIO('q\r\nx\n\r\n')
|
||||
self.assertRaises(
|
||||
exceptions.ReplicationException, self.sender.readline)
|
||||
self.assertTrue(self.sender.response.close_called)
|
||||
|
||||
def test_readline_terminated_chunk(self):
|
||||
self.sender.response = FakeResponse()
|
||||
self.sender.response.fp = StringIO.StringIO('b\r\nnot enough')
|
||||
self.sender.response.fp = six.StringIO('b\r\nnot enough')
|
||||
self.assertRaises(
|
||||
exceptions.ReplicationException, self.sender.readline)
|
||||
self.assertTrue(self.sender.response.close_called)
|
||||
|
||||
def test_readline_all(self):
|
||||
self.sender.response = FakeResponse()
|
||||
self.sender.response.fp = StringIO.StringIO('2\r\nx\n\r\n0\r\n\r\n')
|
||||
self.sender.response.fp = six.StringIO('2\r\nx\n\r\n0\r\n\r\n')
|
||||
self.assertEqual(self.sender.readline(), 'x\n')
|
||||
self.assertEqual(self.sender.readline(), '')
|
||||
self.assertEqual(self.sender.readline(), '')
|
||||
|
||||
def test_readline_all_trailing_not_newline_termed(self):
|
||||
self.sender.response = FakeResponse()
|
||||
self.sender.response.fp = StringIO.StringIO(
|
||||
self.sender.response.fp = six.StringIO(
|
||||
'2\r\nx\n\r\n3\r\n123\r\n0\r\n\r\n')
|
||||
self.assertEqual(self.sender.readline(), 'x\n')
|
||||
self.assertEqual(self.sender.readline(), '123')
|
||||
|
@ -25,7 +25,6 @@ import unittest
|
||||
from contextlib import closing, contextmanager, nested
|
||||
from gzip import GzipFile
|
||||
from shutil import rmtree
|
||||
from StringIO import StringIO
|
||||
import gc
|
||||
import time
|
||||
from textwrap import dedent
|
||||
@ -42,6 +41,7 @@ import random
|
||||
|
||||
import mock
|
||||
from eventlet import sleep, spawn, wsgi, listen, Timeout
|
||||
from six import StringIO
|
||||
from six.moves import range
|
||||
from swift.common.utils import hash_path, json, storage_directory, \
|
||||
parse_content_type, iter_multipart_mime_documents, public
|
||||
|
Loading…
Reference in New Issue
Block a user