summaryrefslogtreecommitdiffstats
path: root/tests/test_exception.py
diff options
context:
space:
mode:
authorLiang Chen <cbjchen@cn.ibm.com>2013-04-14 22:44:12 +0800
committerLiang Chen <cbjchen@cn.ibm.com>2013-04-14 22:44:12 +0800
commitd1da173017216a4506d93203a3c1c2fb6bba96b8 (patch)
tree5a2308146690037652a416aba28a786bb92f72cb /tests/test_exception.py
parentcbac77110ee1d7b9abc5a23f973dab27e8b32015 (diff)
downloadkeystone-d1da173017216a4506d93203a3c1c2fb6bba96b8.tar.gz
keystone-d1da173017216a4506d93203a3c1c2fb6bba96b8.tar.xz
keystone-d1da173017216a4506d93203a3c1c2fb6bba96b8.zip
Enable unicode error message
Keystone exceptions could only take byte string message as the message arguments to construct exception instances because of the way its super class StandardError implements __unicode__. This patch can also make sure it would not unintentionally remove line breaks and indentation in a explicitly given message argument. Fixs bug #1168879 Change-Id: I7916efc87845cfc4dba705e9474125b275affc13
Diffstat (limited to 'tests/test_exception.py')
-rw-r--r--tests/test_exception.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/test_exception.py b/tests/test_exception.py
index dffa14ed..4be470eb 100644
--- a/tests/test_exception.py
+++ b/tests/test_exception.py
@@ -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")