Fix exception to string in py34
python 3.4 does not have a self.message, so we need to set one up in our own base class so the conversion to string work. Change-Id: I5d963125ccb5cc29fa0563313d229046a81ca3d0
This commit is contained in:
@@ -86,6 +86,8 @@ class VMwareDriverException(Exception):
|
|||||||
# at least get the core message out if something happened
|
# at least get the core message out if something happened
|
||||||
message = self.msg_fmt
|
message = self.msg_fmt
|
||||||
|
|
||||||
|
if six.PY3:
|
||||||
|
self.message = message
|
||||||
super(VMwareDriverException, self).__init__(message)
|
super(VMwareDriverException, self).__init__(message)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
"""
|
"""
|
||||||
Unit tests for exceptions module.
|
Unit tests for exceptions module.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from oslo_vmware._i18n import _
|
from oslo_vmware._i18n import _
|
||||||
from oslo_vmware import exceptions
|
from oslo_vmware import exceptions
|
||||||
from oslo_vmware.tests import base
|
from oslo_vmware.tests import base
|
||||||
@@ -79,6 +78,10 @@ class ExceptionsTest(base.TestCase):
|
|||||||
exceptions.register_fault_class,
|
exceptions.register_fault_class,
|
||||||
'ValueError', ValueError)
|
'ValueError', ValueError)
|
||||||
|
|
||||||
|
def test_log_exception_to_string(self):
|
||||||
|
self.assertEqual('Insufficient disk space.',
|
||||||
|
str(exceptions.NoDiskSpaceException()))
|
||||||
|
|
||||||
def test_get_fault_class(self):
|
def test_get_fault_class(self):
|
||||||
self.assertEqual(exceptions.AlreadyExistsException,
|
self.assertEqual(exceptions.AlreadyExistsException,
|
||||||
exceptions.get_fault_class("AlreadyExists"))
|
exceptions.get_fault_class("AlreadyExists"))
|
||||||
|
|||||||
Reference in New Issue
Block a user