Merge "Use six.text_type instead of unicode"
This commit is contained in:
commit
9f30633097
|
@ -14,6 +14,8 @@
|
|||
|
||||
"""Exceptions for the Brick library."""
|
||||
|
||||
import six
|
||||
|
||||
from os_brick.i18n import _, _LE
|
||||
from os_brick.openstack.common import log as logging
|
||||
|
||||
|
@ -64,7 +66,7 @@ class BrickException(Exception):
|
|||
super(BrickException, self).__init__(message)
|
||||
|
||||
def __unicode__(self):
|
||||
return unicode(self.msg)
|
||||
return six.text_type(self.msg)
|
||||
|
||||
|
||||
class NotFound(BrickException):
|
||||
|
|
|
@ -20,6 +20,7 @@ import time
|
|||
|
||||
import mock
|
||||
from oslo_concurrency import processutils as putils
|
||||
import six
|
||||
import testtools
|
||||
|
||||
from os_brick import exception
|
||||
|
@ -722,7 +723,7 @@ class FibreChannelConnectorTestCase(ConnectorTestCase):
|
|||
name = 'volume-00000001'
|
||||
vol = {'id': 1, 'name': name}
|
||||
# Should work for string, unicode, and list
|
||||
wwns = ['1234567890123456', unicode('1234567890123456'),
|
||||
wwns = ['1234567890123456', six.text_type('1234567890123456'),
|
||||
['1234567890123456', '1234567890123457']]
|
||||
for wwn in wwns:
|
||||
connection_info = self.fibrechan_connection(vol, location, wwn)
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import six
|
||||
|
||||
from os_brick import exception
|
||||
from os_brick.tests import base
|
||||
|
||||
|
@ -25,24 +27,26 @@ class BrickExceptionTestCase(base.TestCase):
|
|||
message = "default message"
|
||||
|
||||
exc = FakeBrickException()
|
||||
self.assertEqual(unicode(exc), 'default message')
|
||||
self.assertEqual(six.text_type(exc), 'default message')
|
||||
|
||||
def test_error_msg(self):
|
||||
self.assertEqual(unicode(exception.BrickException('test')), 'test')
|
||||
self.assertEqual(six.text_type(exception.BrickException('test')),
|
||||
'test')
|
||||
|
||||
def test_default_error_msg_with_kwargs(self):
|
||||
class FakeBrickException(exception.BrickException):
|
||||
message = "default message: %(code)s"
|
||||
|
||||
exc = FakeBrickException(code=500)
|
||||
self.assertEqual(unicode(exc), 'default message: 500')
|
||||
self.assertEqual(six.text_type(exc), 'default message: 500')
|
||||
|
||||
def test_error_msg_exception_with_kwargs(self):
|
||||
class FakeBrickException(exception.BrickException):
|
||||
message = "default message: %(mispelled_code)s"
|
||||
|
||||
exc = FakeBrickException(code=500)
|
||||
self.assertEqual(unicode(exc), 'default message: %(mispelled_code)s')
|
||||
self.assertEqual(six.text_type(exc),
|
||||
'default message: %(mispelled_code)s')
|
||||
|
||||
def test_default_error_code(self):
|
||||
class FakeBrickException(exception.BrickException):
|
||||
|
|
Loading…
Reference in New Issue