Delete redundant period in ManilaException messages
--Delete redundant period in the command echo. Change-Id: I0081643b0ba432b327a22473856d06b63f307873 Closes-Bug: #1466062
This commit is contained in:
parent
3c570ddeab
commit
16559b8472
@ -21,6 +21,7 @@ Includes decorator for re-raising Manila-type exceptions.
|
||||
SHOULD include dedicated exception logging.
|
||||
|
||||
"""
|
||||
import re
|
||||
|
||||
from oslo_concurrency import processutils
|
||||
from oslo_config import cfg
|
||||
@ -103,6 +104,8 @@ class ManilaException(Exception):
|
||||
elif isinstance(message, Exception):
|
||||
message = six.text_type(message)
|
||||
|
||||
if re.match('.*[^\.]\.\.$', message):
|
||||
message = message[:-1]
|
||||
self.msg = message
|
||||
super(ManilaException, self).__init__(message)
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import ddt
|
||||
import six
|
||||
|
||||
from manila import exception
|
||||
@ -38,6 +39,7 @@ class FakeNotifier(object):
|
||||
self.provided_payload = payload
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
class ManilaExceptionTestCase(test.TestCase):
|
||||
def test_default_error_msg(self):
|
||||
class FakeManilaException(exception.ManilaException):
|
||||
@ -104,6 +106,18 @@ class ManilaExceptionTestCase(test.TestCase):
|
||||
self.assertNotIn('foo_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):
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user