Merge "Python3: Use six.StringIO for io.Bytes()"

This commit is contained in:
Jenkins
2013-09-11 22:07:13 +00:00
committed by Gerrit Code Review
3 changed files with 11 additions and 13 deletions

View File

@@ -1,7 +1,7 @@
import io
import sys
import mock
import six
from novaclient import exceptions
from novaclient import utils
@@ -112,7 +112,7 @@ class _FakeResult(object):
class PrintResultTestCase(test_utils.TestCase):
@mock.patch('sys.stdout', io.BytesIO())
@mock.patch('sys.stdout', six.StringIO())
def test_print_list_sort_by_str(self):
objs = [_FakeResult("k1", 1),
_FakeResult("k3", 2),
@@ -129,7 +129,7 @@ class PrintResultTestCase(test_utils.TestCase):
'| k3 | 2 |\n'
'+------+-------+\n')
@mock.patch('sys.stdout', io.BytesIO())
@mock.patch('sys.stdout', six.StringIO())
def test_print_list_sort_by_integer(self):
objs = [_FakeResult("k1", 1),
_FakeResult("k3", 2),
@@ -147,7 +147,7 @@ class PrintResultTestCase(test_utils.TestCase):
'+------+-------+\n')
# without sorting
@mock.patch('sys.stdout', io.BytesIO())
@mock.patch('sys.stdout', six.StringIO())
def test_print_list_sort_by_none(self):
objs = [_FakeResult("k1", 1),
_FakeResult("k3", 3),

View File

@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-
import io
import mock
import six
@@ -56,7 +54,7 @@ class ServersTest(utils.TestCase):
key_name="fakekey",
files={
'/etc/passwd': 'some data', # a file
'/tmp/foo.txt': io.BytesIO('data'), # a stream
'/tmp/foo.txt': six.StringIO('data'), # a stream
}
)
cs.assert_called('POST', '/servers')
@@ -100,10 +98,10 @@ class ServersTest(utils.TestCase):
image=1,
flavor=1,
meta={'foo': 'bar'},
userdata=io.BytesIO('hello moto'),
userdata=six.StringIO('hello moto'),
files={
'/etc/passwd': 'some data', # a file
'/tmp/foo.txt': io.BytesIO('data'), # a stream
'/tmp/foo.txt': six.StringIO('data'), # a stream
},
)
cs.assert_called('POST', '/servers')
@@ -119,7 +117,7 @@ class ServersTest(utils.TestCase):
key_name="fakekey",
files={
'/etc/passwd': 'some data', # a file
'/tmp/foo.txt': io.BytesIO('data'), # a stream
'/tmp/foo.txt': six.StringIO('data'), # a stream
},
)
cs.assert_called('POST', '/servers')
@@ -135,7 +133,7 @@ class ServersTest(utils.TestCase):
key_name="fakekey",
files={
'/etc/passwd': 'some data', # a file
'/tmp/foo.txt': io.BytesIO('data'), # a stream
'/tmp/foo.txt': six.StringIO('data'), # a stream
},
)
cs.assert_called('POST', '/servers')

View File

@@ -17,13 +17,13 @@
# under the License.
import datetime
import io
import os
import mock
import sys
import tempfile
import fixtures
import six
import novaclient.client
from novaclient import exceptions
@@ -71,7 +71,7 @@ class ShellTest(utils.TestCase):
lambda *_: fakes.FakeClient))
self.addCleanup(timeutils.clear_time_override)
@mock.patch('sys.stdout', io.BytesIO())
@mock.patch('sys.stdout', six.StringIO())
def run_command(self, cmd):
if isinstance(cmd, list):
self.shell.main(cmd)