summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2015-04-27 14:15:50 +0000
committerGerrit Code Review <review@openstack.org>2015-04-27 14:15:50 +0000
commit9c95882542acd47779066f46bd9b771dc06678f6 (patch)
tree9b8a3eedba3f46b4ca3aee3cd2e9100ae29969aa
parent0bc11890ce146e998d77df007c70505b60634e72 (diff)
parentb0c65f282002070ef1336861f754e9aacc2953bb (diff)
downloadtempest-9c95882542acd47779066f46bd9b771dc06678f6.tar.gz
Merge "Switch all uses of StringIO to use it from six"
-rw-r--r--tempest/api/compute/images/test_image_metadata.py4
-rw-r--r--tempest/api/compute/images/test_list_image_filters.py4
-rw-r--r--tempest/api/compute/test_authorization.py4
-rw-r--r--tempest/api/image/base.py5
-rw-r--r--tempest/api/image/v1/test_images.py9
-rw-r--r--tempest/api/image/v2/test_images.py8
-rw-r--r--tempest/api/object_storage/test_object_services.py4
-rw-r--r--tempest/common/glance_http.py4
-rw-r--r--tempest/common/ssh.py5
-rw-r--r--tempest/tests/test_ssh.py2
-rw-r--r--tempest/tests/test_wrappers.py7
11 files changed, 27 insertions, 29 deletions
diff --git a/tempest/api/compute/images/test_image_metadata.py b/tempest/api/compute/images/test_image_metadata.py
index ab21ad7e2..52d47dd57 100644
--- a/tempest/api/compute/images/test_image_metadata.py
+++ b/tempest/api/compute/images/test_image_metadata.py
@@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
-import StringIO
+import six
from tempest_lib.common.utils import data_utils
@@ -51,7 +51,7 @@ class ImagesMetadataTestJSON(base.BaseV2ComputeTest):
is_public=False)
cls.image_id = body['id']
cls.images.append(cls.image_id)
- image_file = StringIO.StringIO(('*' * 1024))
+ image_file = six.StringIO(('*' * 1024))
cls.glance_client.update_image(cls.image_id, data=image_file)
cls.client.wait_for_image_status(cls.image_id, 'ACTIVE')
diff --git a/tempest/api/compute/images/test_list_image_filters.py b/tempest/api/compute/images/test_list_image_filters.py
index 2c6d2dfa4..430ca3572 100644
--- a/tempest/api/compute/images/test_list_image_filters.py
+++ b/tempest/api/compute/images/test_list_image_filters.py
@@ -13,10 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
-import StringIO
import time
from oslo_log import log as logging
+import six
from tempest_lib.common.utils import data_utils
import testtools
@@ -59,7 +59,7 @@ class ListImageFiltersTestJSON(base.BaseV2ComputeTest):
# Wait 1 second between creation and upload to ensure a delta
# between created_at and updated_at.
time.sleep(1)
- image_file = StringIO.StringIO(('*' * 1024))
+ image_file = six.StringIO(('*' * 1024))
cls.glance_client.update_image(image_id, data=image_file)
cls.client.wait_for_image_status(image_id, 'ACTIVE')
body = cls.client.get_image(image_id)
diff --git a/tempest/api/compute/test_authorization.py b/tempest/api/compute/test_authorization.py
index f9ee75b8b..2baf608d2 100644
--- a/tempest/api/compute/test_authorization.py
+++ b/tempest/api/compute/test_authorization.py
@@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
-import StringIO
+import six
from oslo_log import log as logging
from tempest_lib.common.utils import data_utils
@@ -75,7 +75,7 @@ class AuthorizationTestJSON(base.BaseV2ComputeTest):
disk_format='raw',
is_public=False)
image_id = body['id']
- image_file = StringIO.StringIO(('*' * 1024))
+ image_file = six.StringIO(('*' * 1024))
body = cls.glance_client.update_image(image_id, data=image_file)
cls.glance_client.wait_for_image_status(image_id, 'active')
cls.image = cls.images_client.get_image(image_id)
diff --git a/tempest/api/image/base.py b/tempest/api/image/base.py
index d513b0c6e..74044dc50 100644
--- a/tempest/api/image/base.py
+++ b/tempest/api/image/base.py
@@ -12,9 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-import cStringIO as StringIO
-
from oslo_log import log as logging
+from six import moves
from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
@@ -113,7 +112,7 @@ class BaseV1ImageMembersTest(BaseV1ImageTest):
cls.alt_tenant_id = cls.alt_img_cli.tenant_id
def _create_image(self):
- image_file = StringIO.StringIO(data_utils.random_bytes())
+ image_file = moves.cStringIO(data_utils.random_bytes())
image = self.create_image(container_format='bare',
disk_format='raw',
is_public=False,
diff --git a/tempest/api/image/v1/test_images.py b/tempest/api/image/v1/test_images.py
index bd672c977..49e167b07 100644
--- a/tempest/api/image/v1/test_images.py
+++ b/tempest/api/image/v1/test_images.py
@@ -13,8 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
-import cStringIO as StringIO
-
+from six import moves
from tempest_lib.common.utils import data_utils
from tempest.api.image import base
@@ -46,7 +45,7 @@ class CreateRegisterImagesTest(base.BaseV1ImageTest):
self.assertEqual(val, body.get('properties')[key])
# Now try uploading an image file
- image_file = StringIO.StringIO(data_utils.random_bytes())
+ image_file = moves.cStringIO(data_utils.random_bytes())
body = self.client.update_image(image_id, data=image_file)
self.assertIn('size', body)
self.assertEqual(1024, body.get('size'))
@@ -161,7 +160,7 @@ class ListImagesTest(base.BaseV1ImageTest):
image. Note that the size of the new image is a random number between
1024 and 4096
"""
- image_file = StringIO.StringIO(data_utils.random_bytes(size))
+ image_file = moves.cStringIO(data_utils.random_bytes(size))
name = 'New Standard Image %s' % name
image = cls.create_image(name=name,
container_format=container_format,
@@ -257,7 +256,7 @@ class UpdateImageMetaTest(base.BaseV1ImageTest):
Create a new standard image and return the ID of the newly-registered
image.
"""
- image_file = StringIO.StringIO(data_utils.random_bytes(size))
+ image_file = moves.cStringIO(data_utils.random_bytes(size))
name = 'New Standard Image %s' % name
image = cls.create_image(name=name,
container_format=container_format,
diff --git a/tempest/api/image/v2/test_images.py b/tempest/api/image/v2/test_images.py
index a00296c87..ef0b5f157 100644
--- a/tempest/api/image/v2/test_images.py
+++ b/tempest/api/image/v2/test_images.py
@@ -14,9 +14,9 @@
# License for the specific language governing permissions and limitations
# under the License.
-import cStringIO as StringIO
import random
+from six import moves
from tempest_lib.common.utils import data_utils
from tempest.api.image import base
@@ -55,7 +55,7 @@ class BasicOperationsImagesTest(base.BaseV2ImageTest):
# Now try uploading an image file
file_content = data_utils.random_bytes()
- image_file = StringIO.StringIO(file_content)
+ image_file = moves.cStringIO(file_content)
self.client.store_image(image_id, image_file)
# Now try to get image details
@@ -108,7 +108,7 @@ class BasicOperationsImagesTest(base.BaseV2ImageTest):
image_id = body['id']
# Now try uploading an image file
- image_file = StringIO.StringIO(data_utils.random_bytes())
+ image_file = moves.cStringIO(data_utils.random_bytes())
self.client.store_image(image_id, image_file)
# Update Image
@@ -149,7 +149,7 @@ class ListImagesTest(base.BaseV2ImageTest):
1024 and 4096
"""
size = random.randint(1024, 4096)
- image_file = StringIO.StringIO(data_utils.random_bytes(size))
+ image_file = moves.cStringIO(data_utils.random_bytes(size))
name = data_utils.rand_name('image')
body = cls.create_image(name=name,
container_format=container_format,
diff --git a/tempest/api/object_storage/test_object_services.py b/tempest/api/object_storage/test_object_services.py
index 2091eb5e2..5797e7fe2 100644
--- a/tempest/api/object_storage/test_object_services.py
+++ b/tempest/api/object_storage/test_object_services.py
@@ -13,7 +13,6 @@
# License for the specific language governing permissions and limitations
# under the License.
-import cStringIO as StringIO
import hashlib
import random
import re
@@ -21,6 +20,7 @@ import time
import zlib
import six
+from six import moves
from tempest_lib.common.utils import data_utils
from tempest.api.object_storage import base
@@ -216,7 +216,7 @@ class ObjectTest(base.BaseObjectTest):
status, _, resp_headers = self.object_client.put_object_with_chunk(
container=self.container_name,
name=object_name,
- contents=StringIO.StringIO(data),
+ contents=moves.cStringIO(data),
chunk_size=512)
self.assertHeaders(resp_headers, 'Object', 'PUT')
diff --git a/tempest/common/glance_http.py b/tempest/common/glance_http.py
index c6b8ba3f8..ee07e7366 100644
--- a/tempest/common/glance_http.py
+++ b/tempest/common/glance_http.py
@@ -22,13 +22,13 @@ import json
import posixpath
import re
import socket
-import StringIO
import struct
import urlparse
import OpenSSL
from oslo_log import log as logging
+import six
from six import moves
from tempest_lib import exceptions as lib_exc
@@ -129,7 +129,7 @@ class HTTPClient(object):
# Read body into string if it isn't obviously image data
if resp.getheader('content-type', None) != 'application/octet-stream':
body_str = ''.join([body_chunk for body_chunk in body_iter])
- body_iter = StringIO.StringIO(body_str)
+ body_iter = six.StringIO(body_str)
self._log_response(resp, None)
else:
self._log_response(resp, body_iter)
diff --git a/tempest/common/ssh.py b/tempest/common/ssh.py
index fe67ff802..d0e484cd3 100644
--- a/tempest/common/ssh.py
+++ b/tempest/common/ssh.py
@@ -13,8 +13,6 @@
# License for the specific language governing permissions and limitations
# under the License.
-
-import cStringIO
import select
import socket
import time
@@ -22,6 +20,7 @@ import warnings
from oslo_log import log as logging
import six
+from six import moves
from tempest import exceptions
@@ -43,7 +42,7 @@ class Client(object):
self.password = password
if isinstance(pkey, six.string_types):
pkey = paramiko.RSAKey.from_private_key(
- cStringIO.StringIO(str(pkey)))
+ moves.cStringIO(str(pkey)))
self.pkey = pkey
self.look_for_keys = look_for_keys
self.key_filename = key_filename
diff --git a/tempest/tests/test_ssh.py b/tempest/tests/test_ssh.py
index 27cd6b53a..aaacaab55 100644
--- a/tempest/tests/test_ssh.py
+++ b/tempest/tests/test_ssh.py
@@ -29,7 +29,7 @@ class TestSshClient(base.TestCase):
def test_pkey_calls_paramiko_RSAKey(self):
with contextlib.nested(
mock.patch('paramiko.RSAKey.from_private_key'),
- mock.patch('cStringIO.StringIO')) as (rsa_mock, cs_mock):
+ mock.patch('six.moves.cStringIO')) as (rsa_mock, cs_mock):
cs_mock.return_value = mock.sentinel.csio
pkey = 'mykey'
ssh.Client('localhost', 'root', pkey=pkey)
diff --git a/tempest/tests/test_wrappers.py b/tempest/tests/test_wrappers.py
index ae7860d87..a4ef699c4 100644
--- a/tempest/tests/test_wrappers.py
+++ b/tempest/tests/test_wrappers.py
@@ -14,10 +14,11 @@
import os
import shutil
-import StringIO
import subprocess
import tempfile
+import six
+
from tempest.tests import base
DEVNULL = open(os.devnull, 'wb')
@@ -50,8 +51,8 @@ class TestWrappers(base.TestCase):
shutil.copy('tools/pretty_tox_serial.sh',
os.path.join(self.directory, 'pretty_tox_serial.sh'))
- self.stdout = StringIO.StringIO()
- self.stderr = StringIO.StringIO()
+ self.stdout = six.StringIO()
+ self.stderr = six.StringIO()
# Change directory, run wrapper and check result
self.addCleanup(os.chdir, os.path.abspath(os.curdir))
os.chdir(self.directory)