Remove usage of six
Remove six-library Replace the following items with Python 3 style code. - six.string_types - six.binary_type - six.int2byte - six.u - six.unichr Change-Id: I5b824f13e6c9e9307069fd7fd3eb6d636cf44ca6
This commit is contained in:
parent
fa0a40b8bb
commit
a6ee2d1912
@ -15,8 +15,6 @@
|
||||
|
||||
import struct
|
||||
import urllib.parse as urlparse
|
||||
|
||||
import six
|
||||
import urllib3
|
||||
|
||||
from tempest.api.compute import base
|
||||
@ -122,7 +120,7 @@ class NoVNCConsoleTestJSON(base.BaseV2ComputeTest):
|
||||
'Expected authentication type None.')
|
||||
# Send to the server that we only support authentication
|
||||
# type None
|
||||
self._websocket.send_frame(six.int2byte(1))
|
||||
self._websocket.send_frame(bytes((1,)))
|
||||
|
||||
# The server should send 4 bytes of 0's if security
|
||||
# handshake succeeded
|
||||
@ -135,7 +133,7 @@ class NoVNCConsoleTestJSON(base.BaseV2ComputeTest):
|
||||
'Server did not think security was successful.')
|
||||
|
||||
# Say to leave the desktop as shared as part of client initialization
|
||||
self._websocket.send_frame(six.int2byte(1))
|
||||
self._websocket.send_frame(bytes((1,)))
|
||||
# Get the server initialization packet back and make sure it is the
|
||||
# right structure where bytes 20-24 is the name length and
|
||||
# 24-N is the name
|
||||
|
@ -14,7 +14,6 @@
|
||||
# under the License.
|
||||
|
||||
from oslo_utils import timeutils
|
||||
import six
|
||||
from tempest.api.identity import base
|
||||
from tempest.lib import decorators
|
||||
|
||||
@ -36,7 +35,7 @@ class TokensTest(base.BaseIdentityV2Test):
|
||||
body = token_client.auth(username, password, tenant_name)
|
||||
|
||||
self.assertNotEmpty(body['token']['id'])
|
||||
self.assertIsInstance(body['token']['id'], six.string_types)
|
||||
self.assertIsInstance(body['token']['id'], str)
|
||||
|
||||
now = timeutils.utcnow()
|
||||
expires_at = timeutils.normalize_time(
|
||||
|
@ -16,7 +16,6 @@
|
||||
import operator
|
||||
|
||||
from oslo_utils import timeutils
|
||||
import six
|
||||
|
||||
from tempest.api.identity import base
|
||||
from tempest.lib import decorators
|
||||
@ -88,7 +87,7 @@ class TokensV3Test(base.BaseIdentityV3Test):
|
||||
auth_data=True)
|
||||
|
||||
self.assertNotEmpty(token_id)
|
||||
self.assertIsInstance(token_id, six.string_types)
|
||||
self.assertIsInstance(token_id, str)
|
||||
|
||||
now = timeutils.utcnow()
|
||||
expires_at = timeutils.normalize_time(
|
||||
|
@ -14,8 +14,6 @@
|
||||
# under the License.
|
||||
|
||||
import random
|
||||
|
||||
import six
|
||||
import testtools
|
||||
|
||||
from tempest.api.object_storage import base
|
||||
@ -43,7 +41,7 @@ class AccountTest(base.BaseObjectTest):
|
||||
def resource_setup(cls):
|
||||
super(AccountTest, cls).resource_setup()
|
||||
for i in range(ord('a'), ord('f') + 1):
|
||||
name = data_utils.rand_name(name='%s-' % six.int2byte(i))
|
||||
name = data_utils.rand_name(name='%s-' % bytes((i,)))
|
||||
cls.container_client.update_container(name)
|
||||
cls.addClassResourceCleanup(base.delete_containers,
|
||||
[name],
|
||||
|
@ -12,7 +12,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import six
|
||||
import testtools
|
||||
|
||||
from tempest.lib.common import api_version_request
|
||||
@ -117,7 +116,7 @@ def assert_version_header_matches_request(api_microversion_header_name,
|
||||
:param response_header: Response header where microversion is
|
||||
expected to be present.
|
||||
"""
|
||||
if not isinstance(api_microversion, six.string_types):
|
||||
if not isinstance(api_microversion, str):
|
||||
raise TypeError('api_microversion must be a string')
|
||||
api_microversion_header_name = api_microversion_header_name.lower()
|
||||
if (api_microversion_header_name not in response_header or
|
||||
|
@ -13,7 +13,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import six
|
||||
import urllib3
|
||||
|
||||
|
||||
@ -89,7 +88,7 @@ class ClosingHttp(urllib3.poolmanager.PoolManager):
|
||||
for key, value in info.getheaders().items():
|
||||
# We assume HTTP header name to be string, not random
|
||||
# bytes, thus ensure we have string keys.
|
||||
self[six.u(key).lower()] = value
|
||||
self[str(key).lower()] = value
|
||||
self.status = info.status
|
||||
self['status'] = str(self.status)
|
||||
self.reason = info.reason
|
||||
|
@ -21,7 +21,6 @@ import time
|
||||
import warnings
|
||||
|
||||
from oslo_log import log as logging
|
||||
import six
|
||||
|
||||
from tempest.lib import exceptions
|
||||
|
||||
@ -66,7 +65,7 @@ class Client(object):
|
||||
self.username = username
|
||||
self.port = port
|
||||
self.password = password
|
||||
if isinstance(pkey, six.string_types):
|
||||
if isinstance(pkey, str):
|
||||
pkey = paramiko.RSAKey.from_private_key(
|
||||
io.StringIO(str(pkey)))
|
||||
self.pkey = pkey
|
||||
|
@ -19,7 +19,6 @@ import string
|
||||
import uuid
|
||||
|
||||
from oslo_utils import uuidutils
|
||||
import six.moves
|
||||
|
||||
|
||||
def rand_uuid():
|
||||
@ -171,7 +170,7 @@ def random_bytes(size=1024):
|
||||
"""
|
||||
if size > 1 << 20:
|
||||
raise RuntimeError('Size should be less than 1MiB')
|
||||
return b''.join([six.int2byte(random.randint(0, 255))
|
||||
return b''.join([bytes((random.randint(0, 255),))
|
||||
for i in range(size)])
|
||||
|
||||
|
||||
|
@ -16,7 +16,6 @@ import functools
|
||||
import uuid
|
||||
|
||||
from oslo_log import log as logging
|
||||
import six
|
||||
import testtools
|
||||
|
||||
from tempest.lib import exceptions as lib_exc
|
||||
@ -110,7 +109,7 @@ def related_bug(bug, status_code=None, bug_type='launchpad'):
|
||||
|
||||
def idempotent_id(id):
|
||||
"""Stub for metadata decorator"""
|
||||
if not isinstance(id, six.string_types):
|
||||
if not isinstance(id, str):
|
||||
raise TypeError('Test idempotent_id must be string not %s'
|
||||
'' % type(id).__name__)
|
||||
uuid.UUID(id)
|
||||
@ -140,7 +139,7 @@ def attr(**kwargs):
|
||||
# Check to see if the attr should be conditional applied.
|
||||
if 'condition' in kwargs and not kwargs.get('condition'):
|
||||
return f
|
||||
if 'type' in kwargs and isinstance(kwargs['type'], six.string_types):
|
||||
if 'type' in kwargs and isinstance(kwargs['type'], str):
|
||||
f = testtools.testcase.attr(kwargs['type'])(f)
|
||||
elif 'type' in kwargs and isinstance(kwargs['type'], list):
|
||||
for attr in kwargs['type']:
|
||||
|
@ -20,8 +20,6 @@ import random
|
||||
import time
|
||||
from urllib import parse as urlparse
|
||||
|
||||
import six
|
||||
|
||||
from oslo_serialization import jsonutils as json
|
||||
|
||||
from tempest.lib.common import rest_client
|
||||
@ -35,7 +33,7 @@ class OAUTHTokenClient(rest_client.RestClient):
|
||||
safe = b'~'
|
||||
s = s.encode('utf-8') if isinstance(s, str) else s
|
||||
s = urlparse.quote(s, safe)
|
||||
if isinstance(s, six.binary_type):
|
||||
if isinstance(s, bytes):
|
||||
s = s.decode('utf-8')
|
||||
return s
|
||||
|
||||
|
@ -16,7 +16,6 @@
|
||||
from urllib import parse as urllib
|
||||
|
||||
from oslo_serialization import jsonutils as json
|
||||
import six
|
||||
|
||||
from tempest.lib.common import rest_client
|
||||
from tempest.lib import exceptions as lib_exc
|
||||
@ -31,7 +30,7 @@ class VolumesClient(rest_client.RestClient):
|
||||
If params is a string it will be left as it is, but if it's not it will
|
||||
be urlencoded.
|
||||
"""
|
||||
if isinstance(params, six.string_types):
|
||||
if isinstance(params, str):
|
||||
return params
|
||||
return urllib.urlencode(params)
|
||||
|
||||
|
@ -16,7 +16,6 @@
|
||||
from urllib import parse as urllib
|
||||
|
||||
from oslo_serialization import jsonutils as json
|
||||
import six
|
||||
|
||||
from tempest.lib.api_schema.response.volume import volumes as schema
|
||||
from tempest.lib.common import rest_client
|
||||
@ -33,7 +32,7 @@ class VolumesClient(base_client.BaseClient):
|
||||
If params is a string it will be left as it is, but if it's not it will
|
||||
be urlencoded.
|
||||
"""
|
||||
if isinstance(params, six.string_types):
|
||||
if isinstance(params, str):
|
||||
return params
|
||||
return urllib.urlencode(params)
|
||||
|
||||
|
@ -384,7 +384,7 @@ class BaseTestCase(testtools.testcase.WithAttributes,
|
||||
# This may raise an exception in case credentials are not available
|
||||
# In that case we want to let the exception through and the test
|
||||
# fail accordingly
|
||||
if isinstance(credentials_type, six.string_types):
|
||||
if isinstance(credentials_type, str):
|
||||
manager = cls.get_client_manager(
|
||||
credential_type=credentials_type)
|
||||
setattr(cls, 'os_%s' % credentials_type, manager)
|
||||
@ -859,7 +859,7 @@ class BaseTestCase(testtools.testcase.WithAttributes,
|
||||
"""
|
||||
# Get a manager for the given credentials_type, but at least
|
||||
# always fall back on getting the manager for primary credentials
|
||||
if isinstance(credentials_type, six.string_types):
|
||||
if isinstance(credentials_type, str):
|
||||
manager = cls.get_client_manager(credential_type=credentials_type)
|
||||
elif isinstance(credentials_type, list):
|
||||
scope = 'project'
|
||||
|
@ -16,7 +16,6 @@ from io import StringIO
|
||||
import socket
|
||||
from unittest import mock
|
||||
|
||||
import six
|
||||
import testtools
|
||||
|
||||
from tempest.lib.common import ssh
|
||||
@ -240,7 +239,7 @@ class TestSshClient(base.TestCase):
|
||||
|
||||
return chan_mock, poll_mock, select_mock, client_mock
|
||||
|
||||
_utf8_string = six.unichr(1071)
|
||||
_utf8_string = chr(1071)
|
||||
_utf8_bytes = _utf8_string.encode("utf-8")
|
||||
|
||||
@mock.patch('select.POLLIN', SELECT_POLLIN, create=True)
|
||||
|
Loading…
Reference in New Issue
Block a user