commit 98cf92bdd8cd2f76cddfe4f030e92f0fc5ad4513 Author: gugug Date: Sat May 23 00:27:36 2020 +0800 [part1]:Remove six We don't need this in a Python 3-only world. This ps from six from tests Change-Id: Ic51a74f314078f277b65c0a104a50e0d93b6e727 diff --git a/designate/tests/test_api/test_v2/test_blacklists.py b/designate/tests/test_api/test_v2/test_blacklists.py index 3a8ee75..2dff9b8 100644 --- a/designate/tests/test_api/test_v2/test_blacklists.py +++ b/designate/tests/test_api/test_v2/test_blacklists.py @@ -14,7 +14,6 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -import six from designate.tests.test_api.test_v2 import ApiV2TestCase @@ -150,7 +149,7 @@ class ApiV2BlacklistsTest(ApiV2TestCase): correct_results = [1, 2] for get_url, correct_result in \ - six.moves.zip(get_urls, correct_results): + zip(get_urls, correct_results): self.policy({'find_blacklists': '@'}) response = self.client.get(get_url) diff --git a/designate/tests/test_api/test_v2/test_import_export.py b/designate/tests/test_api/test_v2/test_import_export.py index 836f489..aefc6e1 100644 --- a/designate/tests/test_api/test_v2/test_import_export.py +++ b/designate/tests/test_api/test_v2/test_import_export.py @@ -13,7 +13,6 @@ # under the License. import unittest -import six from dns import zone as dnszone from webtest import TestApp from oslo_config import cfg @@ -113,10 +112,7 @@ class APIV2ZoneImportExportTest(ApiV2TestCase): get_response = self.adminclient.get('/zones/export/%s' % response.json['zone_id'], headers={'Accept': 'text/dns'}) - if six.PY2: - exported_zonefile = get_response.body - else: - exported_zonefile = get_response.body.decode('utf-8') + exported_zonefile = get_response.body.decode('utf-8') imported = dnszone.from_text(self.get_zonefile_fixture()) exported = dnszone.from_text(exported_zonefile) diff --git a/designate/tests/test_api/test_v2/test_pools.py b/designate/tests/test_api/test_v2/test_pools.py index a422ea6..00d8d64 100644 --- a/designate/tests/test_api/test_v2/test_pools.py +++ b/designate/tests/test_api/test_v2/test_pools.py @@ -12,7 +12,6 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -import six from oslo_config import cfg from oslo_log import log as logging @@ -191,7 +190,7 @@ class ApiV2PoolsTest(ApiV2TestCase): correct_results = [1, 1, 0] for get_url, correct_result in \ - six.moves.zip(get_urls, correct_results): + zip(get_urls, correct_results): response = self.client.get(get_url) diff --git a/designate/tests/test_api/test_v2/test_recordsets.py b/designate/tests/test_api/test_v2/test_recordsets.py index 75cf5f9..850ac08 100644 --- a/designate/tests/test_api/test_v2/test_recordsets.py +++ b/designate/tests/test_api/test_v2/test_recordsets.py @@ -15,7 +15,6 @@ # under the License. from unittest.mock import patch -import six import oslo_messaging as messaging from oslo_log import log as logging @@ -348,7 +347,7 @@ class ApiV2RecordSetsTest(ApiV2TestCase): correct_results = [1, 1, 2, 1, 1, 2, 1, 1] for get_url, correct_result in \ - six.moves.zip(get_urls, correct_results): + zip(get_urls, correct_results): response = self.client.get(get_url) diff --git a/designate/tests/test_api/test_v2/test_tlds.py b/designate/tests/test_api/test_v2/test_tlds.py index 1fea074..ff08233 100644 --- a/designate/tests/test_api/test_v2/test_tlds.py +++ b/designate/tests/test_api/test_v2/test_tlds.py @@ -12,7 +12,6 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -import six from designate.tests.test_api.test_v2 import ApiV2TestCase @@ -181,7 +180,7 @@ class ApiV2TldsTest(ApiV2TestCase): correct_results = [1, 2] for get_url, correct_result in \ - six.moves.zip(get_urls, correct_results): + zip(get_urls, correct_results): self.policy({'find_tlds': '@'}) response = self.client.get(get_url) diff --git a/designate/tests/test_hookpoints.py b/designate/tests/test_hookpoints.py index a916a16..bb1c6c9 100644 --- a/designate/tests/test_hookpoints.py +++ b/designate/tests/test_hookpoints.py @@ -16,7 +16,6 @@ from unittest.mock import Mock from unittest.mock import patch -import six from oslo_config import cfg from stevedore.hook import HookManager from stevedore.extension import Extension @@ -104,7 +103,7 @@ class TestHookpointsConfigOpts(TestCase): hp = hook_point('foo') hp.hook_manager = Mock(return_value=get_hook_manager()) hp(inc) - assert hp.group in list(six.iterkeys(self.CONF)) + assert hp.group in self.CONF.keys() class TestHookpointsEnabling(TestCase): diff --git a/designate/tests/unit/__init__.py b/designate/tests/unit/__init__.py index d435e25..865fc27 100644 --- a/designate/tests/unit/__init__.py +++ b/designate/tests/unit/__init__.py @@ -18,8 +18,6 @@ Unit test utilities """ -import six - class RoObject(object): """Read-only object: raise exception on unexpected @@ -50,7 +48,7 @@ class RoObject(object): self.__setitem__(k, v) def __iter__(self): - for k in six.iterkeys(self.__dict__): + for k in self.__dict__: yield k, self.__dict__[k] def to_dict(self): diff --git a/designate/tests/unit/test_central/test_basic.py b/designate/tests/unit/test_central/test_basic.py index ec03384..a02dcce 100644 --- a/designate/tests/unit/test_central/test_basic.py +++ b/designate/tests/unit/test_central/test_basic.py @@ -18,7 +18,6 @@ from unittest import mock from unittest.mock import patch import fixtures -import six import testtools from oslo_config import cfg from oslo_config import fixture as cfg_fixture @@ -631,7 +630,7 @@ class CentralZoneTestCase(CentralBasic): rs_name = 'a' * 255 + '.org.' with testtools.ExpectedException(exceptions.InvalidRecordSetName) as e: self.service._is_valid_recordset_name(self.context, zone, rs_name) - self.assertEqual(six.text_type(e), 'Name too long') + self.assertEqual(str(e), 'Name too long') def test_is_valid_recordset_name_wrong_zone(self): zone = RoObject(name='example.org.') @@ -651,7 +650,7 @@ class CentralZoneTestCase(CentralBasic): ) self.assertEqual( 'CNAME recordsets may not be created at the zone apex', - six.text_type(e)) + str(e)) def test_is_valid_recordset_placement_failing(self): zone = RoObject(name='example.org.', id=CentralZoneTestCase.zone__id) @@ -668,7 +667,7 @@ class CentralZoneTestCase(CentralBasic): ) self.assertEqual( 'CNAME recordsets may not share a name with any other records', - six.text_type(e)) + str(e)) def test_is_valid_recordset_placement_failing_2(self): zone = RoObject(name='example.org.', id=CentralZoneTestCase.zone__id) @@ -686,7 +685,7 @@ class CentralZoneTestCase(CentralBasic): ) self.assertEqual( 'CNAME recordsets may not share a name with any other records', - six.text_type(e)) + str(e)) def test_is_valid_recordset_placement(self): zone = RoObject(name='example.org.', id=CentralZoneTestCase.zone__id) diff --git a/designate/tests/unit/test_utils.py b/designate/tests/unit/test_utils.py index 358a746..62e909d 100644 --- a/designate/tests/unit/test_utils.py +++ b/designate/tests/unit/test_utils.py @@ -213,7 +213,7 @@ class TestUtils(oslotest.base.BaseTestCase): self.assertEqual('Hello World', result) - @mock.patch('six.moves.builtins.open', new_callable=mock.mock_open) + @mock.patch('builtins.open', new_callable=mock.mock_open) @mock.patch('os.path.exists') def test_render_template_to_file(self, mock_exists, mock_open): mock_exists.return_value = True @@ -229,7 +229,7 @@ class TestUtils(oslotest.base.BaseTestCase): mock_open.assert_called_once_with(output_path, 'w') mock_open().write.assert_called_once_with('Hello World') - @mock.patch('six.moves.builtins.open', new_callable=mock.mock_open) + @mock.patch('builtins.open', new_callable=mock.mock_open) @mock.patch('os.path.exists') @mock.patch('os.makedirs') def test_render_template_to_file_with_makedirs(self, mock_makedirs, diff --git a/designate/tests/unit/utils.py b/designate/tests/unit/utils.py index 8226f62..8d1eeb3 100644 --- a/designate/tests/unit/utils.py +++ b/designate/tests/unit/utils.py @@ -11,8 +11,6 @@ # under the License. import functools -import six - def def_method(f, *args, **kwargs): @functools.wraps(f) @@ -52,7 +50,7 @@ def parameterized_class(cls): # To add a method to a class, available for all instances: # MyClass.method = types.MethodType(f, None, MyClass) - setattr(cls, new_name, six.create_unbound_method(new_method, cls)) + setattr(cls, new_name, new_method) return cls diff --git a/tools/pretty_flake8.py b/tools/pretty_flake8.py index ca7a481..82ae16d 100755 --- a/tools/pretty_flake8.py +++ b/tools/pretty_flake8.py @@ -20,7 +20,7 @@ import linecache from prettytable import PrettyTable PEP8_LINE = r'^((?P.*):(?P\d*):(?P\d*):) ' \ - '(?P(?P\w\d{1,3})(?P.*$))' + r'(?P(?P\w\d{1,3})(?P.*$))' HTML = True