Remove six lib

Change-Id: If10f63674f2f7a4c0a38b7f76a2ba8ea86bab3ae
This commit is contained in:
tomas 2021-01-02 16:29:15 +08:00
parent 991e46c1c9
commit 874a778f55
3 changed files with 14 additions and 13 deletions
cyborgclient/tests/unit

@ -12,10 +12,11 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import io
import json import json
from unittest import mock from unittest import mock
import six from http import client as http_client
from cyborgclient.common import httpclient as http from cyborgclient.common import httpclient as http
@ -34,7 +35,7 @@ def _get_error_body(faultstring=None, debuginfo=None):
return raw_body return raw_body
HTTP_CLASS = six.moves.http_client.HTTPConnection HTTP_CLASS = http_client.HTTPConnection
HTTPS_CLASS = http.VerifiedHTTPSConnection HTTPS_CLASS = http.VerifiedHTTPSConnection
DEFAULT_TIMEOUT = 600 DEFAULT_TIMEOUT = 600
@ -64,7 +65,7 @@ class HttpClientTest(utils.BaseTestCase):
def test_server_exception_empty_body(self): def test_server_exception_empty_body(self):
error_body = _get_error_body() error_body = _get_error_body()
fake_resp = utils.FakeResponse({'content-type': 'application/json'}, fake_resp = utils.FakeResponse({'content-type': 'application/json'},
six.StringIO(error_body), io.StringIO(error_body),
version=1, version=1,
status=500) status=500)
client = http.HTTPClient( client = http.HTTPClient(
@ -82,7 +83,7 @@ class HttpClientTest(utils.BaseTestCase):
error_msg = 'test error msg' error_msg = 'test error msg'
error_body = _get_error_body(error_msg) error_body = _get_error_body(error_msg)
fake_resp = utils.FakeResponse({'content-type': 'application/json'}, fake_resp = utils.FakeResponse({'content-type': 'application/json'},
six.StringIO(error_body), io.StringIO(error_body),
version=1, version=1,
status=500) status=500)
client = http.HTTPClient( client = http.HTTPClient(
@ -102,7 +103,7 @@ class HttpClientTest(utils.BaseTestCase):
"File \\\"/usr/local/lib/python2.7/...") "File \\\"/usr/local/lib/python2.7/...")
error_body = _get_error_body(error_msg, error_trace) error_body = _get_error_body(error_msg, error_trace)
fake_resp = utils.FakeResponse({'content-type': 'application/json'}, fake_resp = utils.FakeResponse({'content-type': 'application/json'},
six.StringIO(error_body), io.StringIO(error_body),
version=1, version=1,
status=500) status=500)
client = http.HTTPClient( client = http.HTTPClient(
@ -227,7 +228,7 @@ class HttpClientTest(utils.BaseTestCase):
def test_401_unauthorized_exception(self): def test_401_unauthorized_exception(self):
error_body = _get_error_body() error_body = _get_error_body()
fake_resp = utils.FakeResponse({'content-type': 'text/plain'}, fake_resp = utils.FakeResponse({'content-type': 'text/plain'},
six.StringIO(error_body), io.StringIO(error_body),
version=1, version=1,
status=401) status=401)
client = http.HTTPClient( client = http.HTTPClient(

@ -12,13 +12,13 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import io
import re import re
import sys import sys
from unittest import mock from unittest import mock
import fixtures import fixtures
from keystoneauth1 import fixture from keystoneauth1 import fixture
import six
from testtools import matchers from testtools import matchers
from cyborgclient import exceptions from cyborgclient import exceptions
@ -181,8 +181,8 @@ class ShellTest(utils.TestCase):
self.fail('CommandError not raised') self.fail('CommandError not raised')
@mock.patch('sys.argv', ['cyborg']) @mock.patch('sys.argv', ['cyborg'])
@mock.patch('sys.stdout', six.StringIO()) @mock.patch('sys.stdout', io.StringIO())
@mock.patch('sys.stderr', six.StringIO()) @mock.patch('sys.stderr', io.StringIO())
def test_main_noargs(self): def test_main_noargs(self):
# Ensure that main works with no command-line arguments # Ensure that main works with no command-line arguments
try: try:

@ -18,7 +18,7 @@ import os
import sys import sys
import fixtures import fixtures
import six import io
import testtools import testtools
from cyborgclient.common import httpclient as http from cyborgclient.common import httpclient as http
@ -49,7 +49,7 @@ class FakeAPI(object):
def raw_request(self, *args, **kwargs): def raw_request(self, *args, **kwargs):
response = self._request(*args, **kwargs) response = self._request(*args, **kwargs)
body_iter = http.ResponseBodyIterator(six.StringIO(response[1])) body_iter = http.ResponseBodyIterator(io.StringIO(response[1]))
return FakeResponse(response[0]), body_iter return FakeResponse(response[0]), body_iter
def json_request(self, *args, **kwargs): def json_request(self, *args, **kwargs):
@ -142,8 +142,8 @@ class TestCase(testtools.TestCase):
orig = sys.stdout orig = sys.stdout
orig_stderr = sys.stderr orig_stderr = sys.stderr
try: try:
sys.stdout = six.StringIO() sys.stdout = io.StringIO()
sys.stderr = six.StringIO() sys.stderr = io.StringIO()
_shell = shell.OpenStackCyborgShell() _shell = shell.OpenStackCyborgShell()
_shell.main(argstr.split()) _shell.main(argstr.split())
except SystemExit: except SystemExit: