Python 3: Fix module names in import
Use six.moves to fix imports on Python 3. Change-Id: I35b9405690e9f0607b24d79aa7c00830df954c41
This commit is contained in:
parent
cdf6f84c36
commit
e3b7ecd2bb
@ -25,8 +25,8 @@ import warnings
|
||||
|
||||
from distutils.version import StrictVersion
|
||||
from requests.exceptions import RequestException, SSLError
|
||||
from urllib import quote as _quote
|
||||
from urlparse import urlparse, urlunparse
|
||||
from six.moves.urllib.parse import quote as _quote
|
||||
from six.moves.urllib.parse import urlparse, urlunparse
|
||||
from time import sleep, time
|
||||
|
||||
from swiftclient.exceptions import ClientException, InvalidHeadersException
|
||||
|
@ -15,7 +15,7 @@
|
||||
from itertools import chain
|
||||
import sys
|
||||
from time import sleep
|
||||
from Queue import Queue
|
||||
from six.moves.queue import Queue
|
||||
from threading import Thread
|
||||
from traceback import format_exception
|
||||
|
||||
|
@ -18,8 +18,8 @@ import time
|
||||
import mock
|
||||
import testtools
|
||||
import threading
|
||||
from cStringIO import StringIO
|
||||
from Queue import Queue, Empty
|
||||
import six
|
||||
from six.moves.queue import Queue, Empty
|
||||
|
||||
from swiftclient import multithreading as mt
|
||||
from swiftclient.exceptions import ClientException
|
||||
@ -287,8 +287,8 @@ class TestMultiThreadingManager(ThreadTestCase):
|
||||
], mock_qfq.call_args_list)
|
||||
|
||||
def test_printers(self):
|
||||
out_stream = StringIO()
|
||||
err_stream = StringIO()
|
||||
out_stream = six.StringIO()
|
||||
err_stream = six.StringIO()
|
||||
|
||||
with mt.MultiThreadingManager(
|
||||
print_stream=out_stream,
|
||||
|
@ -20,7 +20,8 @@ import six
|
||||
import socket
|
||||
import testtools
|
||||
import warnings
|
||||
from urlparse import urlparse
|
||||
from six.moves.urllib.parse import urlparse
|
||||
from six.moves import reload_module
|
||||
|
||||
# TODO: mock http connection class with more control over headers
|
||||
from .utils import fake_http_connect, fake_get_keystoneclient_2_0
|
||||
@ -62,14 +63,14 @@ class TestJsonImport(testtools.TestCase):
|
||||
except ImportError:
|
||||
pass
|
||||
else:
|
||||
reload(json)
|
||||
reload_module(json)
|
||||
|
||||
try:
|
||||
import simplejson
|
||||
except ImportError:
|
||||
pass
|
||||
else:
|
||||
reload(simplejson)
|
||||
reload_module(simplejson)
|
||||
super(TestJsonImport, self).tearDown()
|
||||
|
||||
def test_any(self):
|
||||
@ -84,7 +85,7 @@ class TestJsonImport(testtools.TestCase):
|
||||
pass
|
||||
else:
|
||||
delattr(simplejson, 'loads')
|
||||
reload(c)
|
||||
reload_module(c)
|
||||
|
||||
try:
|
||||
from json import loads
|
||||
@ -137,7 +138,7 @@ class MockHttpTest(testtools.TestCase):
|
||||
|
||||
def tearDown(self):
|
||||
super(MockHttpTest, self).tearDown()
|
||||
reload(c)
|
||||
reload_module(c)
|
||||
|
||||
|
||||
class MockHttpResponse():
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
import testtools
|
||||
|
||||
from StringIO import StringIO
|
||||
import six
|
||||
import tempfile
|
||||
|
||||
from swiftclient import utils as u
|
||||
@ -125,7 +125,7 @@ class TestPrtBytes(testtools.TestCase):
|
||||
class TestLengthWrapper(testtools.TestCase):
|
||||
|
||||
def test_stringio(self):
|
||||
contents = StringIO('a' * 100)
|
||||
contents = six.StringIO('a' * 100)
|
||||
data = u.LengthWrapper(contents, 42)
|
||||
self.assertEqual(42, len(data))
|
||||
read_data = ''.join(iter(data.read, ''))
|
||||
|
Loading…
x
Reference in New Issue
Block a user