Merge "Get StringIO from six for Python 3 compatibility"
This commit is contained in:
commit
eebc694df2
@ -15,9 +15,9 @@
|
||||
|
||||
import contextlib
|
||||
import os
|
||||
import StringIO
|
||||
|
||||
import mock
|
||||
import six
|
||||
|
||||
from cinder import context
|
||||
from cinder.tests.unit.targets import targets_fixture as tf
|
||||
@ -50,7 +50,7 @@ class TestCxtAdmDriver(tf.TargetDriverFixture):
|
||||
self.assertTrue(m_exec.called)
|
||||
|
||||
def test_get_target_chap_auth(self):
|
||||
tmp_file = StringIO.StringIO()
|
||||
tmp_file = six.StringIO()
|
||||
tmp_file.write(
|
||||
'target:\n'
|
||||
' TargetName=iqn.2010-10.org.openstack:volume-83c2e877-feed-46be-8435-77884fe55b45\n' # noqa
|
||||
|
@ -12,11 +12,9 @@
|
||||
|
||||
import contextlib
|
||||
|
||||
import StringIO
|
||||
|
||||
|
||||
import mock
|
||||
from oslo_concurrency import processutils as putils
|
||||
import six
|
||||
|
||||
from cinder import context
|
||||
from cinder import exception
|
||||
@ -34,7 +32,7 @@ class TestIetAdmDriver(tf.TargetDriverFixture):
|
||||
configuration=self.configuration)
|
||||
|
||||
def test_get_target(self):
|
||||
tmp_file = StringIO.StringIO()
|
||||
tmp_file = six.StringIO()
|
||||
tmp_file.write(
|
||||
'tid:1 name:iqn.2010-10.org.openstack:volume-83c2e877-feed-46be-8435-77884fe55b45\n' # noqa
|
||||
' sid:844427031282176 initiator:iqn.1994-05.com.redhat:5a6894679665\n' # noqa
|
||||
@ -56,7 +54,7 @@ class TestIetAdmDriver(tf.TargetDriverFixture):
|
||||
@mock.patch('os.path.exists', return_value=True)
|
||||
@mock.patch('cinder.utils.temporary_chown')
|
||||
def test_get_target_chap_auth(self, mock_chown, mock_exists):
|
||||
tmp_file = StringIO.StringIO()
|
||||
tmp_file = six.StringIO()
|
||||
tmp_file.write(
|
||||
'Target iqn.2010-10.org.openstack:volume-83c2e877-feed-46be-8435-77884fe55b45\n' # noqa
|
||||
' IncomingUser otzLy2UYbYfnP4zXLG5z 234Zweo38VGBBvrpK9nt\n'
|
||||
@ -87,7 +85,7 @@ class TestIetAdmDriver(tf.TargetDriverFixture):
|
||||
def test_create_iscsi_target(self, mock_chown, mock_exists,
|
||||
mock_execute, mock_get_targ):
|
||||
mock_execute.return_value = ('', '')
|
||||
tmp_file = StringIO.StringIO()
|
||||
tmp_file = six.StringIO()
|
||||
with mock.patch('__builtin__.open') as mock_open:
|
||||
mock_open.return_value = contextlib.closing(tmp_file)
|
||||
self.assertEqual(
|
||||
@ -175,7 +173,7 @@ class TestIetAdmDriver(tf.TargetDriverFixture):
|
||||
self.testvol['name'])
|
||||
|
||||
def test_find_sid_cid_for_target(self):
|
||||
tmp_file = StringIO.StringIO()
|
||||
tmp_file = six.StringIO()
|
||||
tmp_file.write(
|
||||
'tid:1 name:iqn.2010-10.org.openstack:volume-83c2e877-feed-46be-8435-77884fe55b45\n' # noqa
|
||||
' sid:844427031282176 initiator:iqn.1994-05.com.redhat:5a6894679665\n' # noqa
|
||||
|
@ -19,11 +19,11 @@ Self test for Hitachi Unified Storage (HUS-HNAS) platform.
|
||||
"""
|
||||
|
||||
import os
|
||||
import StringIO
|
||||
import tempfile
|
||||
|
||||
import mock
|
||||
from oslo_log import log as logging
|
||||
import six
|
||||
|
||||
from cinder import exception
|
||||
from cinder import test
|
||||
@ -329,18 +329,18 @@ class HNASiSCSIDriverTest(test.TestCase):
|
||||
def test_read_config(self, m_access, m_open):
|
||||
# Test exception when file is not found
|
||||
m_access.return_value = False
|
||||
m_open.return_value = StringIO.StringIO(HNASCONF)
|
||||
m_open.return_value = six.StringIO(HNASCONF)
|
||||
self.assertRaises(exception.NotFound, iscsi._read_config, '')
|
||||
|
||||
# Test exception when config file has parsing errors
|
||||
# due to missing <svc> tag
|
||||
m_access.return_value = True
|
||||
m_open.return_value = StringIO.StringIO(HNAS_WRONG_CONF1)
|
||||
m_open.return_value = six.StringIO(HNAS_WRONG_CONF1)
|
||||
self.assertRaises(exception.ConfigNotFound, iscsi._read_config, '')
|
||||
|
||||
# Test exception when config file has parsing errors
|
||||
# due to missing <hdp> tag
|
||||
m_open.return_value = StringIO.StringIO(HNAS_WRONG_CONF2)
|
||||
m_open.return_value = six.StringIO(HNAS_WRONG_CONF2)
|
||||
self.configuration.hds_hnas_iscsi_config_file = ''
|
||||
self.assertRaises(exception.ParameterNotFound, iscsi._read_config, '')
|
||||
|
||||
|
@ -15,11 +15,11 @@
|
||||
#
|
||||
|
||||
import os
|
||||
import StringIO
|
||||
import tempfile
|
||||
|
||||
import mock
|
||||
from oslo_log import log as logging
|
||||
import six
|
||||
|
||||
from cinder import exception
|
||||
from cinder import test
|
||||
@ -191,18 +191,18 @@ class HDSNFSDriverTest(test.TestCase):
|
||||
def test_read_config(self, m_access, m_open):
|
||||
# Test exception when file is not found
|
||||
m_access.return_value = False
|
||||
m_open.return_value = StringIO.StringIO(HNASCONF)
|
||||
m_open.return_value = six.StringIO(HNASCONF)
|
||||
self.assertRaises(exception.NotFound, nfs._read_config, '')
|
||||
|
||||
# Test exception when config file has parsing errors
|
||||
# due to missing <svc> tag
|
||||
m_access.return_value = True
|
||||
m_open.return_value = StringIO.StringIO(HNAS_WRONG_CONF1)
|
||||
m_open.return_value = six.StringIO(HNAS_WRONG_CONF1)
|
||||
self.assertRaises(exception.ConfigNotFound, nfs._read_config, '')
|
||||
|
||||
# Test exception when config file has parsing errors
|
||||
# due to missing <hdp> tag
|
||||
m_open.return_value = StringIO.StringIO(HNAS_WRONG_CONF2)
|
||||
m_open.return_value = six.StringIO(HNAS_WRONG_CONF2)
|
||||
self.configuration.hds_hnas_iscsi_config_file = ''
|
||||
self.assertRaises(exception.ParameterNotFound, nfs._read_config, '')
|
||||
|
||||
|
@ -18,7 +18,6 @@
|
||||
import errno
|
||||
import os
|
||||
import six
|
||||
import StringIO
|
||||
import traceback
|
||||
|
||||
import mock
|
||||
@ -130,7 +129,7 @@ class QuobyteDriverTestCase(test.TestCase):
|
||||
mock.patch('cinder.volume.drivers.quobyte.QuobyteDriver'
|
||||
'.read_proc_mount') as mock_open:
|
||||
# Content of /proc/mount (not mounted yet).
|
||||
mock_open.return_value = StringIO.StringIO(
|
||||
mock_open.return_value = six.StringIO(
|
||||
"/dev/sda5 / ext4 rw,relatime,data=ordered 0 0")
|
||||
|
||||
self._driver._mount_quobyte(self.TEST_QUOBYTE_VOLUME,
|
||||
@ -154,7 +153,7 @@ class QuobyteDriverTestCase(test.TestCase):
|
||||
mock.patch('cinder.volume.drivers.quobyte.QuobyteDriver'
|
||||
'.read_proc_mount') as mock_open:
|
||||
# Content of /proc/mount (already mounted).
|
||||
mock_open.return_value = StringIO.StringIO(
|
||||
mock_open.return_value = six.StringIO(
|
||||
"quobyte@%s %s fuse rw,nosuid,nodev,noatime,user_id=1000"
|
||||
",group_id=100,default_permissions,allow_other 0 0"
|
||||
% (self.TEST_QUOBYTE_VOLUME, self.TEST_MNT_POINT))
|
||||
@ -180,7 +179,7 @@ class QuobyteDriverTestCase(test.TestCase):
|
||||
'.read_proc_mount') as mock_open, \
|
||||
mock.patch('cinder.volume.drivers.quobyte.LOG') as mock_LOG:
|
||||
# Content of /proc/mount (empty).
|
||||
mock_open.return_value = StringIO.StringIO()
|
||||
mock_open.return_value = six.StringIO()
|
||||
mock_execute.side_effect = [None, putils.ProcessExecutionError(
|
||||
stderr='is busy or already mounted')]
|
||||
|
||||
@ -206,7 +205,7 @@ class QuobyteDriverTestCase(test.TestCase):
|
||||
with mock.patch.object(self._driver, '_execute') as mock_execute, \
|
||||
mock.patch('cinder.volume.drivers.quobyte.QuobyteDriver'
|
||||
'.read_proc_mount') as mock_open:
|
||||
mock_open.return_value = StringIO.StringIO()
|
||||
mock_open.return_value = six.StringIO()
|
||||
mock_execute.side_effect = [
|
||||
None, # mkdir
|
||||
putils.ProcessExecutionError( # mount
|
||||
|
@ -16,10 +16,10 @@ ZFS Storage Appliance REST API Client Programmatic Interface
|
||||
"""
|
||||
|
||||
import json
|
||||
import StringIO
|
||||
import time
|
||||
|
||||
from oslo_log import log
|
||||
import six
|
||||
from six.moves import http_client
|
||||
from six.moves import urllib
|
||||
|
||||
@ -226,7 +226,7 @@ class RestClientURL(object):
|
||||
:cmd_params args: The path part
|
||||
:cmd_params kwargs: The query part
|
||||
"""
|
||||
buf = StringIO.StringIO()
|
||||
buf = six.StringIO()
|
||||
query = "?"
|
||||
for arg in args:
|
||||
buf.write("/")
|
||||
|
Loading…
x
Reference in New Issue
Block a user