Merge "Delete redundant period in ManilaException messages"
This commit is contained in:
commit
ac55cf6ba3
@ -21,6 +21,7 @@ Includes decorator for re-raising Manila-type exceptions.
|
|||||||
SHOULD include dedicated exception logging.
|
SHOULD include dedicated exception logging.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
import re
|
||||||
|
|
||||||
from oslo_concurrency import processutils
|
from oslo_concurrency import processutils
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
@ -103,6 +104,8 @@ class ManilaException(Exception):
|
|||||||
elif isinstance(message, Exception):
|
elif isinstance(message, Exception):
|
||||||
message = six.text_type(message)
|
message = six.text_type(message)
|
||||||
|
|
||||||
|
if re.match('.*[^\.]\.\.$', message):
|
||||||
|
message = message[:-1]
|
||||||
self.msg = message
|
self.msg = message
|
||||||
super(ManilaException, self).__init__(message)
|
super(ManilaException, self).__init__(message)
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import ddt
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from manila import exception
|
from manila import exception
|
||||||
@ -38,6 +39,7 @@ class FakeNotifier(object):
|
|||||||
self.provided_payload = payload
|
self.provided_payload = payload
|
||||||
|
|
||||||
|
|
||||||
|
@ddt.ddt
|
||||||
class ManilaExceptionTestCase(test.TestCase):
|
class ManilaExceptionTestCase(test.TestCase):
|
||||||
def test_default_error_msg(self):
|
def test_default_error_msg(self):
|
||||||
class FakeManilaException(exception.ManilaException):
|
class FakeManilaException(exception.ManilaException):
|
||||||
@ -104,6 +106,18 @@ class ManilaExceptionTestCase(test.TestCase):
|
|||||||
self.assertNotIn('foo_msg', exc.kwargs)
|
self.assertNotIn('foo_msg', exc.kwargs)
|
||||||
self.assertNotIn('bar_msg', exc.kwargs)
|
self.assertNotIn('bar_msg', exc.kwargs)
|
||||||
|
|
||||||
|
@ddt.data("test message.", "test message....", ".")
|
||||||
|
def test_exception_not_redundant_period(self, msg):
|
||||||
|
exc1 = Exception(msg)
|
||||||
|
exc2 = exception.ManilaException(exc1)
|
||||||
|
self.assertEqual(msg, exc2.msg)
|
||||||
|
|
||||||
|
def test_exception_redundant_period(self):
|
||||||
|
msg = "test message.."
|
||||||
|
exc1 = Exception(msg)
|
||||||
|
exc2 = exception.ManilaException(exc1)
|
||||||
|
self.assertEqual("test message.", exc2.msg)
|
||||||
|
|
||||||
|
|
||||||
class ManilaExceptionResponseCode400(test.TestCase):
|
class ManilaExceptionResponseCode400(test.TestCase):
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user