Merge "Error class can accept message with format characters"

This commit is contained in:
Jenkins 2014-09-05 19:51:50 +00:00 committed by Gerrit Code Review
commit 227e84dc30
2 changed files with 10 additions and 3 deletions

View File

@ -324,9 +324,10 @@ class EgressRuleNotAllowed(HeatException):
class Error(HeatException):
def __init__(self, msg_fmt):
self.msg_fmt = msg_fmt
super(Error, self).__init__()
msg_fmt = "%(message)s"
def __init__(self, msg):
super(Error, self).__init__(message=msg)
class NotFound(HeatException):

View File

@ -16,6 +16,7 @@
import fixtures
import six
from heat.common import exception
from heat.tests import common
@ -32,3 +33,8 @@ class TestHeatException(common.HeatTestCase):
'heat.common.exception._FATAL_EXCEPTION_FORMAT_ERRORS',
True))
self.assertRaises(KeyError, TestException)
def test_format_string_error_message(self):
message = "This format %(message)s should work"
err = exception.Error(message)
self.assertEqual(message, six.text_type(err))