Fix test_exception.py for py34

test_exception.py was failing on py34 because the test assumed that
UnicodeDecodeError would happen, but on python 3 the replacement
doesn't fail.

bp python3

Change-Id: Ia778c3ea39260a29670488d32f63cfdb032911c2
This commit is contained in:
Brant Knudson 2015-07-22 21:03:07 -05:00
parent a9c794ae5e
commit 21b0abb7c3
2 changed files with 11 additions and 2 deletions

View File

@ -87,7 +87,10 @@ class ExceptionTestCase(tests.BaseTestCase):
e = exception.ValidationError(attribute='xx',
target='Long \xe2\x80\x93 Dash')
self.assertIn(u'\u2013', six.text_type(e))
if six.PY2:
self.assertIn(u'\u2013', six.text_type(e))
else:
self.assertIn('Long \xe2\x80\x93 Dash', six.text_type(e))
def test_invalid_unicode_string(self):
# NOTE(jamielennox): This is a complete failure case so what is
@ -95,7 +98,12 @@ class ExceptionTestCase(tests.BaseTestCase):
# as there is an error with a message
e = exception.ValidationError(attribute='xx',
target='\xe7a va')
self.assertIn('%(attribute)', six.text_type(e))
if six.PY2:
self.assertIn('%(attribute)', six.text_type(e))
else:
# There's no UnicodeDecodeError on python 3.
self.assertIn('\xe7a va', six.text_type(e))
class UnexpectedExceptionTestCase(ExceptionTestCase):

View File

@ -29,6 +29,7 @@ commands =
keystone/tests/unit/test_backend_rules.py \
keystone/tests/unit/test_cache_backend_mongo.py \
keystone/tests/unit/test_driver_hints.py \
keystone/tests/unit/test_exception.py \
keystone/tests/unit/test_policy.py \
keystone/tests/unit/test_singular_plural.py \
keystone/tests/unit/test_sql_livetest.py \