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