From 2cd21156383d8cd08df14149fef1782a7873d165 Mon Sep 17 00:00:00 2001 From: Chuck Short Date: Thu, 10 Oct 2013 13:24:03 -0400 Subject: [PATCH] use six.StringIO for compatibility with io.StringIO in python3 The newer version of six (1.4.1) provides six.StringIO which is a fake file object for textual data. It's an alias for cStringIO.StringIO, in python2 and io.StringIO in Python3. Change-Id: If1ccfca128385f976938f0f0c74573687faad9ac Signed-off-by: Chuck Short --- keystoneclient/tests/test_shell.py | 4 ++-- keystoneclient/tests/v2_0/test_shell.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/keystoneclient/tests/test_shell.py b/keystoneclient/tests/test_shell.py index 10e7ae942..93935ed20 100644 --- a/keystoneclient/tests/test_shell.py +++ b/keystoneclient/tests/test_shell.py @@ -13,7 +13,6 @@ # under the License. import argparse -import cStringIO import json import os import sys @@ -21,6 +20,7 @@ import uuid import fixtures import mock +import six import testtools from testtools import matchers @@ -80,7 +80,7 @@ class ShellTest(utils.TestCase): clean_env = {} _old_env, os.environ = os.environ, clean_env.copy() try: - sys.stdout = cStringIO.StringIO() + sys.stdout = six.StringIO() _shell = openstack_shell.OpenStackIdentityShell() _shell.main(argstr.split()) except SystemExit: diff --git a/keystoneclient/tests/v2_0/test_shell.py b/keystoneclient/tests/v2_0/test_shell.py index 9eae6e111..3ae49e5ab 100644 --- a/keystoneclient/tests/v2_0/test_shell.py +++ b/keystoneclient/tests/v2_0/test_shell.py @@ -12,11 +12,11 @@ # License for the specific language governing permissions and limitations # under the License. -import cStringIO import os import sys from mox3 import stubout +import six from testtools import matchers from keystoneclient import httpclient @@ -69,7 +69,7 @@ class ShellTests(utils.TestCase): def run_command(self, cmd): orig = sys.stdout try: - sys.stdout = cStringIO.StringIO() + sys.stdout = six.StringIO() if isinstance(cmd, list): self.shell.main(cmd) else: