commit 919cbbd4df426487f8ca751b245bccff7549fa04 Author: xuanyandong Date: Thu Oct 8 09:36:16 2020 +0800 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 diff --git a/cinder/tests/functional/api/client.py b/cinder/tests/functional/api/client.py index f65491b..7049776 100644 --- a/cinder/tests/functional/api/client.py +++ b/cinder/tests/functional/api/client.py @@ -12,11 +12,12 @@ # License for the specific language governing permissions and limitations # under the License. +from http import client as http_client +import urllib + from oslo_serialization import jsonutils from oslo_utils import netutils import requests -from six.moves import http_client -from six.moves import urllib from cinder.i18n import _ from cinder.tests.unit import fake_constants as fake diff --git a/cinder/tests/functional/api_samples_test_base.py b/cinder/tests/functional/api_samples_test_base.py index 204b124..d5d0a9c 100644 --- a/cinder/tests/functional/api_samples_test_base.py +++ b/cinder/tests/functional/api_samples_test_base.py @@ -15,7 +15,6 @@ import pprint import re from oslo_serialization import jsonutils -import six from cinder.tests.functional import functional_helpers from cinder.tests.unit import test @@ -89,7 +88,7 @@ class ApiSampleTestBase(functional_helpers._FunctionalTestBase): non_strings = \ {k: v for k, v in value.items() if (not k == 'volume_host') and - (not isinstance(v, six.string_types))} + (not isinstance(v, str))} if len(non_strings) > 0: raise TypeError("subs can't contain non-string values:" "\n%(non_strings)s" % @@ -269,7 +268,7 @@ class ApiSampleTestBase(functional_helpers._FunctionalTestBase): matched_value = self._compare_list( expected, result, result_str, matched_value) # template string - elif isinstance(expected, six.string_types) and '%' in expected: + elif isinstance(expected, str) and '%' in expected: if expected[-1] == '%': if result != expected: raise NoMatch( @@ -282,11 +281,11 @@ class ApiSampleTestBase(functional_helpers._FunctionalTestBase): matched_value = self._compare_template( expected, result, result_str, matched_value) # string - elif isinstance(expected, six.string_types): + elif isinstance(expected, str): # Ignore whitespace in this comparison expected = expected.strip() - if isinstance(result, six.string_types): + if isinstance(result, str): result = result.strip() if expected != result: @@ -297,7 +296,7 @@ class ApiSampleTestBase(functional_helpers._FunctionalTestBase): 'result_str': result_str, 'result': result}) # int - elif isinstance(expected, (six.integer_types, float)): + elif isinstance(expected, (int, float)): if expected != result: raise NoMatch( 'Values do not match:\n' diff --git a/cinder/tests/functional/test_extensions.py b/cinder/tests/functional/test_extensions.py index ae312f4..ff54429 100644 --- a/cinder/tests/functional/test_extensions.py +++ b/cinder/tests/functional/test_extensions.py @@ -13,11 +13,11 @@ # License for the specific language governing permissions and limitations # under the License. +from http import client as http_client import iso8601 from oslo_config import cfg from oslo_serialization import jsonutils -from six.moves import http_client import webob from cinder.api import extensions diff --git a/cinder/tests/hacking/checks.py b/cinder/tests/hacking/checks.py index f508532..3494c6e 100644 --- a/cinder/tests/hacking/checks.py +++ b/cinder/tests/hacking/checks.py @@ -16,7 +16,6 @@ import ast import re from hacking import core -import six """ Guidelines for writing new hacking checks @@ -182,7 +181,7 @@ class CheckLoggingFormatArgs(BaseASTChecker): if obj_name is None: return None return obj_name + '.' + method_name - elif isinstance(node, six.string_types): + elif isinstance(node, str): return node else: # could be Subscript, Call or many more return None @@ -251,7 +250,7 @@ class CheckOptRegistrationArgs(BaseASTChecker): if obj_name is None: return None return obj_name + '.' + method_name - elif isinstance(node, six.string_types): + elif isinstance(node, str): return node else: # could be Subscript, Call or many more return None