Merge "[part1]:Remove six"

This commit is contained in:
Zuul 2020-10-14 13:32:58 +00:00 committed by Gerrit Code Review
commit 75dc32815c
11 changed files with 15 additions and 29 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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):

View File

@ -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):

View File

@ -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)

View File

@ -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,

View File

@ -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

View File

@ -19,7 +19,7 @@ import linecache
from prettytable import PrettyTable
PEP8_LINE = r'^((?P<file>.*):(?P<line>\d*):(?P<col>\d*):) ' \
'(?P<error>(?P<error_code>\w\d{1,3})(?P<error_desc>.*$))'
r'(?P<error>(?P<error_code>\w\d{1,3})(?P<error_desc>.*$))'
HTML = True