summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChuck Short <chuck.short@canonical.com>2013-05-24 10:35:28 -0500
committerChuck Short <chuck.short@canonical.com>2013-05-24 10:35:28 -0500
commitc90c85212f5ab989c29ebc07cc8dcdebc1991fcb (patch)
treefb60225d7917a17b187a2ec7df382cf817d9be6d
parent7fa8325525f7dd1802261a071dad1f5effd9b95a (diff)
downloadoslo-serialization-c90c85212f5ab989c29ebc07cc8dcdebc1991fcb.tar.gz
python3: python3 binary/text data compatbility
Python3 enforces the distinction between byte strings far more rigorously than Python 2 does; binary data cannot be automatically coerced to or from text data. Use six to provide a fake file object for textual data. It provides an alias for StringIO.StringIO in python2 and io.StringIO in python3 Change-Id: I65897bb0cca2cbeb5819a769b98645c9eb066401 Signed-off-by: Chuck Short <chuck.short@canonical.com>
-rw-r--r--tests/unit/test_jsonutils.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/tests/unit/test_jsonutils.py b/tests/unit/test_jsonutils.py
index 35a9487..758455b 100644
--- a/tests/unit/test_jsonutils.py
+++ b/tests/unit/test_jsonutils.py
@@ -16,9 +16,10 @@
# under the License.
import datetime
-import StringIO
import xmlrpclib
+from six import StringIO
+
from openstack.common import jsonutils
from tests import utils
@@ -32,7 +33,7 @@ class JSONUtilsTestCase(utils.BaseTestCase):
self.assertEqual(jsonutils.loads('{"a": "b"}'), {'a': 'b'})
def test_load(self):
- x = StringIO.StringIO('{"a": "b"}')
+ x = StringIO('{"a": "b"}')
self.assertEqual(jsonutils.load(x), {'a': 'b'})