From fcf289797c063088f9003359dfd1c7d4f41ed5ef Mon Sep 17 00:00:00 2001 From: Henry Gessau Date: Wed, 23 Sep 2015 13:31:50 -0400 Subject: [PATCH] Py3k compliance: check for bytes when making a string When faking stdout in tests we must account for the case when "strings" might be bytes, which python3 cares about. Change-Id: I0e9349c86371055eed479799d39ab6adbcad6f95 Closes-Bug: #1499004 --- neutronclient/tests/unit/test_cli20.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/neutronclient/tests/unit/test_cli20.py b/neutronclient/tests/unit/test_cli20.py index 94d979cf0..240d8c911 100644 --- a/neutronclient/tests/unit/test_cli20.py +++ b/neutronclient/tests/unit/test_cli20.py @@ -73,6 +73,12 @@ class FakeStdout(object): def make_string(self): result = '' for line in self.content: + if six.PY3: + if isinstance(line, bytes): + try: + line = line.decode(encoding='utf-8') + except UnicodeError: + pass result = result + line return result