summaryrefslogtreecommitdiffstats
path: root/tests/test_exception.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_exception.py')
-rw-r--r--tests/test_exception.py32
1 files changed, 20 insertions, 12 deletions
diff --git a/tests/test_exception.py b/tests/test_exception.py
index 33250835..d442d572 100644
--- a/tests/test_exception.py
+++ b/tests/test_exception.py
@@ -67,14 +67,14 @@ class ExceptionTestCase(test.TestCase):
attribute = uuid.uuid4().hex
e = exception.ValidationError(target=target, attribute=attribute)
self.assertValidJsonRendering(e)
- self.assertIn(target, str(e))
- self.assertIn(attribute, str(e))
+ self.assertIn(target, unicode(e))
+ self.assertIn(attribute, unicode(e))
def test_not_found(self):
target = uuid.uuid4().hex
e = exception.NotFound(target=target)
self.assertValidJsonRendering(e)
- self.assertIn(target, str(e))
+ self.assertIn(target, unicode(e))
def test_403_title(self):
e = exception.Forbidden()
@@ -101,7 +101,7 @@ class SecurityErrorTestCase(ExceptionTestCase):
risky_info = uuid.uuid4().hex
e = exception.Unauthorized(message=risky_info)
self.assertValidJsonRendering(e)
- self.assertNotIn(risky_info, str(e))
+ self.assertNotIn(risky_info, unicode(e))
def test_unauthorized_exposure_in_debug(self):
self.opt(debug=True)
@@ -109,7 +109,7 @@ class SecurityErrorTestCase(ExceptionTestCase):
risky_info = uuid.uuid4().hex
e = exception.Unauthorized(message=risky_info)
self.assertValidJsonRendering(e)
- self.assertIn(risky_info, str(e))
+ self.assertIn(risky_info, unicode(e))
def test_forbidden_exposure(self):
self.opt(debug=False)
@@ -117,7 +117,7 @@ class SecurityErrorTestCase(ExceptionTestCase):
risky_info = uuid.uuid4().hex
e = exception.Forbidden(message=risky_info)
self.assertValidJsonRendering(e)
- self.assertNotIn(risky_info, str(e))
+ self.assertNotIn(risky_info, unicode(e))
def test_forbidden_exposure_in_debug(self):
self.opt(debug=True)
@@ -125,7 +125,7 @@ class SecurityErrorTestCase(ExceptionTestCase):
risky_info = uuid.uuid4().hex
e = exception.Forbidden(message=risky_info)
self.assertValidJsonRendering(e)
- self.assertIn(risky_info, str(e))
+ self.assertIn(risky_info, unicode(e))
def test_forbidden_action_exposure(self):
self.opt(debug=False)
@@ -134,12 +134,12 @@ class SecurityErrorTestCase(ExceptionTestCase):
action = uuid.uuid4().hex
e = exception.ForbiddenAction(message=risky_info, action=action)
self.assertValidJsonRendering(e)
- self.assertNotIn(risky_info, str(e))
- self.assertIn(action, str(e))
+ self.assertNotIn(risky_info, unicode(e))
+ self.assertIn(action, unicode(e))
e = exception.ForbiddenAction(action=risky_info)
self.assertValidJsonRendering(e)
- self.assertIn(risky_info, str(e))
+ self.assertIn(risky_info, unicode(e))
def test_forbidden_action_exposure_in_debug(self):
self.opt(debug=True)
@@ -148,8 +148,16 @@ class SecurityErrorTestCase(ExceptionTestCase):
e = exception.ForbiddenAction(message=risky_info)
self.assertValidJsonRendering(e)
- self.assertIn(risky_info, str(e))
+ self.assertIn(risky_info, unicode(e))
e = exception.ForbiddenAction(action=risky_info)
self.assertValidJsonRendering(e)
- self.assertIn(risky_info, str(e))
+ self.assertIn(risky_info, unicode(e))
+
+ def test_unicode_argument_message(self):
+ self.opt(debug=False)
+
+ risky_info = u'\u7ee7\u7eed\u884c\u7f29\u8fdb\u6216'
+ e = exception.Forbidden(message=risky_info)
+ self.assertValidJsonRendering(e)
+ self.assertNotIn(risky_info, unicode(e))