diff --git a/swiftclient/client.py b/swiftclient/client.py index ad778175..5ebbcf2b 100644 --- a/swiftclient/client.py +++ b/swiftclient/client.py @@ -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 diff --git a/swiftclient/multithreading.py b/swiftclient/multithreading.py index cd3c57cd..b98702d4 100644 --- a/swiftclient/multithreading.py +++ b/swiftclient/multithreading.py @@ -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 diff --git a/tests/test_multithreading.py b/tests/test_multithreading.py index c12f20ca..b5668378 100644 --- a/tests/test_multithreading.py +++ b/tests/test_multithreading.py @@ -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, diff --git a/tests/test_swiftclient.py b/tests/test_swiftclient.py index 8f709472..f9e20223 100644 --- a/tests/test_swiftclient.py +++ b/tests/test_swiftclient.py @@ -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(): diff --git a/tests/test_utils.py b/tests/test_utils.py index 4c4b29de..d9d74c5b 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -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, ''))