From 874a778f55d953f4f56d65ffe035edb10c7f37aa Mon Sep 17 00:00:00 2001 From: tomas Date: Sat, 2 Jan 2021 16:29:15 +0800 Subject: [PATCH] Remove six lib Change-Id: If10f63674f2f7a4c0a38b7f76a2ba8ea86bab3ae --- cyborgclient/tests/unit/common/test_httpclient.py | 13 +++++++------ cyborgclient/tests/unit/test_shell.py | 6 +++--- cyborgclient/tests/unit/utils.py | 8 ++++---- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/cyborgclient/tests/unit/common/test_httpclient.py b/cyborgclient/tests/unit/common/test_httpclient.py index f08057c..960759d 100644 --- a/cyborgclient/tests/unit/common/test_httpclient.py +++ b/cyborgclient/tests/unit/common/test_httpclient.py @@ -12,10 +12,11 @@ # License for the specific language governing permissions and limitations # under the License. +import io import json from unittest import mock -import six +from http import client as http_client from cyborgclient.common import httpclient as http @@ -34,7 +35,7 @@ def _get_error_body(faultstring=None, debuginfo=None): return raw_body -HTTP_CLASS = six.moves.http_client.HTTPConnection +HTTP_CLASS = http_client.HTTPConnection HTTPS_CLASS = http.VerifiedHTTPSConnection DEFAULT_TIMEOUT = 600 @@ -64,7 +65,7 @@ class HttpClientTest(utils.BaseTestCase): def test_server_exception_empty_body(self): error_body = _get_error_body() fake_resp = utils.FakeResponse({'content-type': 'application/json'}, - six.StringIO(error_body), + io.StringIO(error_body), version=1, status=500) client = http.HTTPClient( @@ -82,7 +83,7 @@ class HttpClientTest(utils.BaseTestCase): error_msg = 'test error msg' error_body = _get_error_body(error_msg) fake_resp = utils.FakeResponse({'content-type': 'application/json'}, - six.StringIO(error_body), + io.StringIO(error_body), version=1, status=500) client = http.HTTPClient( @@ -102,7 +103,7 @@ class HttpClientTest(utils.BaseTestCase): "File \\\"/usr/local/lib/python2.7/...") error_body = _get_error_body(error_msg, error_trace) fake_resp = utils.FakeResponse({'content-type': 'application/json'}, - six.StringIO(error_body), + io.StringIO(error_body), version=1, status=500) client = http.HTTPClient( @@ -227,7 +228,7 @@ class HttpClientTest(utils.BaseTestCase): def test_401_unauthorized_exception(self): error_body = _get_error_body() fake_resp = utils.FakeResponse({'content-type': 'text/plain'}, - six.StringIO(error_body), + io.StringIO(error_body), version=1, status=401) client = http.HTTPClient( diff --git a/cyborgclient/tests/unit/test_shell.py b/cyborgclient/tests/unit/test_shell.py index 442af60..6c04fb7 100644 --- a/cyborgclient/tests/unit/test_shell.py +++ b/cyborgclient/tests/unit/test_shell.py @@ -12,13 +12,13 @@ # License for the specific language governing permissions and limitations # under the License. +import io import re import sys from unittest import mock import fixtures from keystoneauth1 import fixture -import six from testtools import matchers from cyborgclient import exceptions @@ -181,8 +181,8 @@ class ShellTest(utils.TestCase): self.fail('CommandError not raised') @mock.patch('sys.argv', ['cyborg']) - @mock.patch('sys.stdout', six.StringIO()) - @mock.patch('sys.stderr', six.StringIO()) + @mock.patch('sys.stdout', io.StringIO()) + @mock.patch('sys.stderr', io.StringIO()) def test_main_noargs(self): # Ensure that main works with no command-line arguments try: diff --git a/cyborgclient/tests/unit/utils.py b/cyborgclient/tests/unit/utils.py index ad271dd..900fdd3 100644 --- a/cyborgclient/tests/unit/utils.py +++ b/cyborgclient/tests/unit/utils.py @@ -18,7 +18,7 @@ import os import sys import fixtures -import six +import io import testtools from cyborgclient.common import httpclient as http @@ -49,7 +49,7 @@ class FakeAPI(object): def raw_request(self, *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 def json_request(self, *args, **kwargs): @@ -142,8 +142,8 @@ class TestCase(testtools.TestCase): orig = sys.stdout orig_stderr = sys.stderr try: - sys.stdout = six.StringIO() - sys.stderr = six.StringIO() + sys.stdout = io.StringIO() + sys.stderr = io.StringIO() _shell = shell.OpenStackCyborgShell() _shell.main(argstr.split()) except SystemExit: