Remove six of dir cinder/tests/functional&hacking/*

Replace the following items with Python 3 style code.

- six.moves
- six.string_types

Change-Id: Ibabf36a4b1aea9df39291883aef77b0c29b18df6
Implements: blueprint six-removal
This commit is contained in:
xuanyandong 2020-10-08 09:36:16 +08:00
parent 6ad1ab0c72
commit 919cbbd4df
4 changed files with 11 additions and 12 deletions

View File

@ -12,11 +12,12 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from http import client as http_client
import urllib
from oslo_serialization import jsonutils from oslo_serialization import jsonutils
from oslo_utils import netutils from oslo_utils import netutils
import requests import requests
from six.moves import http_client
from six.moves import urllib
from cinder.i18n import _ from cinder.i18n import _
from cinder.tests.unit import fake_constants as fake from cinder.tests.unit import fake_constants as fake

View File

@ -15,7 +15,6 @@ import pprint
import re import re
from oslo_serialization import jsonutils from oslo_serialization import jsonutils
import six
from cinder.tests.functional import functional_helpers from cinder.tests.functional import functional_helpers
from cinder.tests.unit import test from cinder.tests.unit import test
@ -89,7 +88,7 @@ class ApiSampleTestBase(functional_helpers._FunctionalTestBase):
non_strings = \ non_strings = \
{k: v for k, v in value.items() if {k: v for k, v in value.items() if
(not k == 'volume_host') and (not k == 'volume_host') and
(not isinstance(v, six.string_types))} (not isinstance(v, str))}
if len(non_strings) > 0: if len(non_strings) > 0:
raise TypeError("subs can't contain non-string values:" raise TypeError("subs can't contain non-string values:"
"\n%(non_strings)s" % "\n%(non_strings)s" %
@ -269,7 +268,7 @@ class ApiSampleTestBase(functional_helpers._FunctionalTestBase):
matched_value = self._compare_list( matched_value = self._compare_list(
expected, result, result_str, matched_value) expected, result, result_str, matched_value)
# template string # template string
elif isinstance(expected, six.string_types) and '%' in expected: elif isinstance(expected, str) and '%' in expected:
if expected[-1] == '%': if expected[-1] == '%':
if result != expected: if result != expected:
raise NoMatch( raise NoMatch(
@ -282,11 +281,11 @@ class ApiSampleTestBase(functional_helpers._FunctionalTestBase):
matched_value = self._compare_template( matched_value = self._compare_template(
expected, result, result_str, matched_value) expected, result, result_str, matched_value)
# string # string
elif isinstance(expected, six.string_types): elif isinstance(expected, str):
# Ignore whitespace in this comparison # Ignore whitespace in this comparison
expected = expected.strip() expected = expected.strip()
if isinstance(result, six.string_types): if isinstance(result, str):
result = result.strip() result = result.strip()
if expected != result: if expected != result:
@ -297,7 +296,7 @@ class ApiSampleTestBase(functional_helpers._FunctionalTestBase):
'result_str': result_str, 'result_str': result_str,
'result': result}) 'result': result})
# int # int
elif isinstance(expected, (six.integer_types, float)): elif isinstance(expected, (int, float)):
if expected != result: if expected != result:
raise NoMatch( raise NoMatch(
'Values do not match:\n' 'Values do not match:\n'

View File

@ -13,11 +13,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.
from http import client as http_client
import iso8601 import iso8601
from oslo_config import cfg from oslo_config import cfg
from oslo_serialization import jsonutils from oslo_serialization import jsonutils
from six.moves import http_client
import webob import webob
from cinder.api import extensions from cinder.api import extensions

View File

@ -16,7 +16,6 @@ import ast
import re import re
from hacking import core from hacking import core
import six
""" """
Guidelines for writing new hacking checks Guidelines for writing new hacking checks
@ -182,7 +181,7 @@ class CheckLoggingFormatArgs(BaseASTChecker):
if obj_name is None: if obj_name is None:
return None return None
return obj_name + '.' + method_name return obj_name + '.' + method_name
elif isinstance(node, six.string_types): elif isinstance(node, str):
return node return node
else: # could be Subscript, Call or many more else: # could be Subscript, Call or many more
return None return None
@ -251,7 +250,7 @@ class CheckOptRegistrationArgs(BaseASTChecker):
if obj_name is None: if obj_name is None:
return None return None
return obj_name + '.' + method_name return obj_name + '.' + method_name
elif isinstance(node, six.string_types): elif isinstance(node, str):
return node return node
else: # could be Subscript, Call or many more else: # could be Subscript, Call or many more
return None return None