summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2014-01-31 03:34:00 +0000
committerGerrit Code Review <review@openstack.org>2014-01-31 03:34:00 +0000
commit456afa153d0fd831686a50c19cc195da2820a6dd (patch)
treec24e5c682fab4853e7064a71a5062a6fc82fdf2a
parent661e306f5541d6077a2fb5257754742f4bdc9af0 (diff)
parent31695d1eb54242c3a4976a8a7ee15a489e5d0878 (diff)
downloadpython-keystoneclient-456afa153d0fd831686a50c19cc195da2820a6dd.tar.gz
Merge "Python 3: fix tests/test_utils.py"0.5.0
-rw-r--r--keystoneclient/tests/test_utils.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/keystoneclient/tests/test_utils.py b/keystoneclient/tests/test_utils.py
index f560b3a..fe0f907 100644
--- a/keystoneclient/tests/test_utils.py
+++ b/keystoneclient/tests/test_utils.py
@@ -120,9 +120,19 @@ class PrintTestCase(test_utils.TestCase):
# NOTE(Jeffrey4l) If the text's encode is proper, this method will not
# raise UnicodeEncodeError exceptions
utils.print_list(objs, ['name'])
- self.assertIn(name, self.stdout.getvalue().decode('utf8'))
+ output = self.stdout.getvalue()
+ # In Python 2, output will be bytes, while in Python 3, it will not.
+ # Let's decode the value if needed.
+ if isinstance(output, six.binary_type):
+ output = output.decode('utf-8')
+ self.assertIn(name, output)
def test_print_dict_unicode(self):
name = u'\u540d\u5b57'
utils.print_dict({'name': name})
- self.assertIn(name, self.stdout.getvalue().decode('utf8'))
+ output = self.stdout.getvalue()
+ # In Python 2, output will be bytes, while in Python 3, it will not.
+ # Let's decode the value if needed.
+ if isinstance(output, six.binary_type):
+ output = output.decode('utf-8')
+ self.assertIn(name, output)