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:
Davanum Srinivas 2015-06-27 21:44:01 -04:00
parent bbf6d0cc69
commit d388c8a67b
2 changed files with 6 additions and 1 deletions

View File

@ -86,6 +86,8 @@ class VMwareDriverException(Exception):
# at least get the core message out if something happened
message = self.msg_fmt
if six.PY3:
self.message = message
super(VMwareDriverException, self).__init__(message)
@property

View File

@ -16,7 +16,6 @@
"""
Unit tests for exceptions module.
"""
from oslo_vmware._i18n import _
from oslo_vmware import exceptions
from oslo_vmware.tests import base
@ -79,6 +78,10 @@ class ExceptionsTest(base.TestCase):
exceptions.register_fault_class,
'ValueError', ValueError)
def test_log_exception_to_string(self):
self.assertEqual('Insufficient disk space.',
str(exceptions.NoDiskSpaceException()))
def test_get_fault_class(self):
self.assertEqual(exceptions.AlreadyExistsException,
exceptions.get_fault_class("AlreadyExists"))