Merge "Enable unicode error message"
This commit is contained in:
commit
cb0ddabff3
|
@ -56,14 +56,10 @@ class Error(StandardError):
|
|||
:raises: KeyError given insufficient kwargs
|
||||
|
||||
"""
|
||||
return message or self.__doc__ % kwargs
|
||||
|
||||
def __str__(self):
|
||||
"""Cleans up line breaks and indentation from doc strings."""
|
||||
string = super(Error, self).__str__()
|
||||
string = re.sub('[ \n]+', ' ', string)
|
||||
string = string.strip()
|
||||
return string
|
||||
if not message:
|
||||
message = re.sub('[ \n]+', ' ', self.__doc__ % kwargs)
|
||||
message = message.strip()
|
||||
return message
|
||||
|
||||
|
||||
class ValidationError(Error):
|
||||
|
|
|
@ -136,3 +136,12 @@ class SecurityErrorTestCase(ExceptionTestCase):
|
|||
e = exception.ForbiddenAction(action=risky_info)
|
||||
self.assertValidJsonRendering(e)
|
||||
self.assertIn(risky_info, str(e))
|
||||
|
||||
def test_unicode_message(self):
|
||||
message = u'Comment \xe7a va'
|
||||
e = exception.Error(message)
|
||||
self.assertEqual(e.message, message)
|
||||
try:
|
||||
unicode(e)
|
||||
except UnicodeEncodeError:
|
||||
self.fail("unicode error message not supported")
|
||||
|
|
Loading…
Reference in New Issue