From 72c6dc564a79e55b39269db46d1849e58adfeb78 Mon Sep 17 00:00:00 2001 From: xuanyandong Date: Thu, 8 Oct 2020 13:49:15 +0800 Subject: [PATCH] Remove six of files under cinder/test/unit Replace the following items with Python 3 style code. - six.PY3 - six.add_metaclass - six.string_types - six.text_type - six.moves - six.StringIO - six.reraise - six.wraps Change-Id: Id27e6823244bc6a81ce1301b32cee79dd99e771a Implements: blueprint six-removal --- cinder/tests/unit/fake_utils.py | 3 +- cinder/tests/unit/test.py | 14 +++---- cinder/tests/unit/test_api.py | 7 ++-- cinder/tests/unit/test_cmd.py | 51 ++++++++++++------------- cinder/tests/unit/test_db_api.py | 3 +- cinder/tests/unit/test_db_worker_api.py | 3 +- cinder/tests/unit/test_exception.py | 23 +++++------ cinder/tests/unit/test_manager.py | 6 +-- cinder/tests/unit/test_qos_specs.py | 3 +- cinder/tests/unit/test_quota.py | 5 +-- cinder/tests/unit/test_utils.py | 4 +- cinder/tests/unit/test_volume_utils.py | 15 ++++---- cinder/tests/unit/utils.py | 4 +- 13 files changed, 62 insertions(+), 79 deletions(-) diff --git a/cinder/tests/unit/fake_utils.py b/cinder/tests/unit/fake_utils.py index a535453ea0b..8fa5cb3d5a6 100644 --- a/cinder/tests/unit/fake_utils.py +++ b/cinder/tests/unit/fake_utils.py @@ -17,7 +17,6 @@ import re from eventlet import greenthread -import six _fake_execute_repliers = [] _fake_execute_log = [] @@ -71,7 +70,7 @@ def fake_execute(*cmd_parts, **kwargs): reply_handler = fake_replier[1] break - if isinstance(reply_handler, six.string_types): + if isinstance(reply_handler, str): # If the reply handler is a string, return it as stdout reply = reply_handler, '' else: diff --git a/cinder/tests/unit/test.py b/cinder/tests/unit/test.py index 319d2e8e1df..739b61ca792 100644 --- a/cinder/tests/unit/test.py +++ b/cinder/tests/unit/test.py @@ -38,7 +38,6 @@ from oslo_messaging import conffixture as messaging_conffixture from oslo_serialization import jsonutils from oslo_utils import strutils from oslo_utils import timeutils -import six import testtools from cinder.api import common as api_common @@ -283,12 +282,11 @@ class TestCase(testtools.TestCase): coordination.COORDINATOR.start() self.addCleanup(coordination.COORDINATOR.stop) - if six.PY3: - # TODO(smcginnis) Python 3 deprecates assertRaisesRegexp to - # assertRaisesRegex, but Python 2 does not have the new name. This - # can be removed once we stop supporting py2 or the new name is - # added. - self.assertRaisesRegexp = self.assertRaisesRegex + # TODO(smcginnis) Python 3 deprecates assertRaisesRegexp to + # assertRaisesRegex, but Python 2 does not have the new name. This + # can be removed once we stop supporting py2 or the new name is + # added. + self.assertRaisesRegexp = self.assertRaisesRegex # Ensure we have the default tpool size value and we don't carry # threads from other test runs. @@ -471,7 +469,7 @@ class ModelsObjectComparatorMixin(object): self.assertEqual( len(obj1), len(obj2), - "Keys mismatch: %s" % six.text_type( + "Keys mismatch: %s" % str( set(obj1.keys()) ^ set(obj2.keys()))) for key, value in obj1.items(): self.assertEqual(value, obj2[key]) diff --git a/cinder/tests/unit/test_api.py b/cinder/tests/unit/test_api.py index bb96cb2fabd..f9c0dc1bd5b 100644 --- a/cinder/tests/unit/test_api.py +++ b/cinder/tests/unit/test_api.py @@ -17,8 +17,9 @@ """Unit tests for the API endpoint.""" -import six -from six.moves import http_client +from http import client as http_client +import io + import webob @@ -26,7 +27,7 @@ class FakeHttplibSocket(object): """A fake socket implementation for http_client.HTTPResponse, trivial.""" def __init__(self, response_string): self.response_string = response_string - self._buffer = six.StringIO(response_string) + self._buffer = io.StringIO(response_string) def makefile(self, _mode, _other): """Returns the socket's internal buffer.""" diff --git a/cinder/tests/unit/test_cmd.py b/cinder/tests/unit/test_cmd.py index 49665ea601a..7620c5f6997 100644 --- a/cinder/tests/unit/test_cmd.py +++ b/cinder/tests/unit/test_cmd.py @@ -11,6 +11,7 @@ # under the License. import datetime +import io import re import sys import time @@ -22,8 +23,6 @@ import iso8601 from oslo_config import cfg from oslo_db import exception as oslo_exception from oslo_utils import timeutils -import six -from six.moves import StringIO # Prevent load failures on macOS if sys.platform == 'darwin': @@ -382,7 +381,7 @@ class TestCinderManageCmd(test.TestCase): @mock.patch('oslo_db.sqlalchemy.migration.db_version') def test_db_commands_version(self, db_version): db_cmds = cinder_manage.DbCommands() - with mock.patch('sys.stdout', new=six.StringIO()): + with mock.patch('sys.stdout', new=io.StringIO()): db_cmds.version() self.assertEqual(1, db_version.call_count) @@ -423,7 +422,7 @@ class TestCinderManageCmd(test.TestCase): @mock.patch('cinder.context.get_admin_context') def test_online_migrations(self, mock_get_context): - self.useFixture(fixtures.MonkeyPatch('sys.stdout', StringIO())) + self.useFixture(fixtures.MonkeyPatch('sys.stdout', io.StringIO())) ctxt = mock_get_context.return_value db_cmds = self._fake_db_command() command = db_cmds() @@ -455,7 +454,7 @@ class TestCinderManageCmd(test.TestCase): @mock.patch('cinder.context.get_admin_context') def test_online_migrations_no_max_count(self, mock_get_context): - self.useFixture(fixtures.MonkeyPatch('sys.stdout', StringIO())) + self.useFixture(fixtures.MonkeyPatch('sys.stdout', io.StringIO())) fake_remaining = [120] def fake_migration(context, count): @@ -492,7 +491,7 @@ class TestCinderManageCmd(test.TestCase): @mock.patch('cinder.context.get_admin_context') def test_online_migrations_error(self, mock_get_context): - self.useFixture(fixtures.MonkeyPatch('sys.stdout', StringIO())) + self.useFixture(fixtures.MonkeyPatch('sys.stdout', io.StringIO())) good_remaining = [50] def good_migration(context, count): @@ -562,14 +561,14 @@ class TestCinderManageCmd(test.TestCase): @mock.patch('cinder.version.version_string') def test_versions_commands_list(self, version_string): version_cmds = cinder_manage.VersionCommands() - with mock.patch('sys.stdout', new=six.StringIO()): + with mock.patch('sys.stdout', new=io.StringIO()): version_cmds.list() version_string.assert_called_once_with() @mock.patch('cinder.version.version_string') def test_versions_commands_call(self, version_string): version_cmds = cinder_manage.VersionCommands() - with mock.patch('sys.stdout', new=six.StringIO()): + with mock.patch('sys.stdout', new=io.StringIO()): version_cmds.__call__() version_string.assert_called_once_with() @@ -608,7 +607,7 @@ class TestCinderManageCmd(test.TestCase): 'availability_zone': 'fake-az', 'uuid': 'a3a593da-7f8d-4bb7-8b4c-f2bc1e0b4824'}] - with mock.patch('sys.stdout', new=six.StringIO()) as fake_out: + with mock.patch('sys.stdout', new=io.StringIO()) as fake_out: expected_out = ("%(host)-25s\t%(zone)-15s\n" % {'host': 'host', 'zone': 'zone'}) expected_out += ("%(host)-25s\t%(availability_zone)-15s\n" % @@ -634,7 +633,7 @@ class TestCinderManageCmd(test.TestCase): 'availability_zone': 'fake-az2', 'uuid': '4200b32b-0bf9-436c-86b2-0675f6ac218e'}] - with mock.patch('sys.stdout', new=six.StringIO()) as fake_out: + with mock.patch('sys.stdout', new=io.StringIO()) as fake_out: expected_out = ("%(host)-25s\t%(zone)-15s\n" % {'host': 'host', 'zone': 'zone'}) expected_out += ("%(host)-25s\t%(availability_zone)-15s\n" % @@ -695,7 +694,7 @@ class TestCinderManageCmd(test.TestCase): volume_id = volume['id'] volume_get.return_value = volume - with mock.patch('sys.stdout', new=six.StringIO()) as fake_out: + with mock.patch('sys.stdout', new=io.StringIO()) as fake_out: expected_out = ('Volume not yet assigned to host.\n' 'Deleting volume from database and skipping' ' rpc.\n') @@ -723,7 +722,7 @@ class TestCinderManageCmd(test.TestCase): volume_id = volume['id'] volume_get.return_value = volume - with mock.patch('sys.stdout', new=six.StringIO()) as fake_out: + with mock.patch('sys.stdout', new=io.StringIO()) as fake_out: expected_out = ('Volume is in-use.\n' 'Detach volume from instance and then try' ' again.\n') @@ -734,7 +733,7 @@ class TestCinderManageCmd(test.TestCase): self.assertEqual(expected_out, fake_out.getvalue()) def test_config_commands_list(self): - with mock.patch('sys.stdout', new=six.StringIO()) as fake_out: + with mock.patch('sys.stdout', new=io.StringIO()) as fake_out: expected_out = '' for key, value in CONF.items(): expected_out += '%s = %s' % (key, value) + '\n' @@ -745,7 +744,7 @@ class TestCinderManageCmd(test.TestCase): self.assertEqual(expected_out, fake_out.getvalue()) def test_config_commands_list_param(self): - with mock.patch('sys.stdout', new=six.StringIO()) as fake_out: + with mock.patch('sys.stdout', new=io.StringIO()) as fake_out: CONF.set_override('host', 'fake') expected_out = 'host = fake\n' @@ -772,7 +771,7 @@ class TestCinderManageCmd(test.TestCase): 'backup_metadata': {}, } backup_get_all.return_value = [backup] - with mock.patch('sys.stdout', new=six.StringIO()) as fake_out: + with mock.patch('sys.stdout', new=io.StringIO()) as fake_out: hdr = ('%-32s\t%-32s\t%-32s\t%-24s\t%-24s\t%-12s\t%-12s\t%-12s' '\t%-12s') header = hdr % ('ID', @@ -869,7 +868,7 @@ class TestCinderManageCmd(test.TestCase): get_admin_context.return_value = ctxt service_get_all.return_value = [service] service_is_up.return_value = True - with mock.patch('sys.stdout', new=six.StringIO()) as fake_out: + with mock.patch('sys.stdout', new=io.StringIO()) as fake_out: format = "%-16s %-36s %-16s %-10s %-5s %-20s %-12s %-15s %-36s" print_format = format % ('Binary', 'Host', @@ -964,7 +963,7 @@ class TestCinderManageCmd(test.TestCase): ctxt = context.RequestContext(fake.USER_ID, fake.PROJECT_ID) get_admin_mock.return_value = ctxt - with mock.patch('sys.stdout', new=six.StringIO()) as fake_out: + with mock.patch('sys.stdout', new=io.StringIO()) as fake_out: format_ = "%-36s %-16s %-10s %-5s %-20s %-7s %-12s %-20s" print_format = format_ % ('Name', 'Binary', @@ -1114,7 +1113,7 @@ class TestCinderManageCmd(test.TestCase): sys.argv = [script_name] CONF(sys.argv[1:], project='cinder', version=version.version_string()) - with mock.patch('sys.stdout', new=six.StringIO()): + with mock.patch('sys.stdout', new=io.StringIO()): exit = self.assertRaises(SystemExit, cinder_manage.main) self.assertTrue(register_cli_opt.called) self.assertEqual(2, exit.code) @@ -1129,7 +1128,7 @@ class TestCinderManageCmd(test.TestCase): config_opts_call.side_effect = cfg.ConfigFilesNotFoundError( mock.sentinel._namespace) - with mock.patch('sys.stdout', new=six.StringIO()): + with mock.patch('sys.stdout', new=io.StringIO()): exit = self.assertRaises(SystemExit, cinder_manage.main) self.assertTrue(register_cli_opt.called) @@ -1165,7 +1164,7 @@ class TestCinderManageCmd(test.TestCase): sys.argv = [script_name, '--config-dir', fake_dir] config_opts_call.side_effect = cfg.ConfigDirNotFoundError(fake_dir) - with mock.patch('sys.stdout', new=six.StringIO()) as fake_out: + with mock.patch('sys.stdout', new=io.StringIO()) as fake_out: exit = self.assertRaises(SystemExit, cinder_manage.main) self.assertTrue(register_cli_opt.called) config_opts_call.assert_called_once_with( @@ -1208,7 +1207,7 @@ class TestCinderRtstoolCmd(test.TestCase): def test_create_rtslib_error(self, rtsroot): rtsroot.side_effect = rtslib_fb.utils.RTSLibError() - with mock.patch('sys.stdout', new=six.StringIO()): + with mock.patch('sys.stdout', new=io.StringIO()): self.assertRaises(rtslib_fb.utils.RTSLibError, cinder_rtstool.create, mock.sentinel.backing_device, @@ -1270,11 +1269,11 @@ class TestCinderRtstoolCmd(test.TestCase): network_portal.assert_any_call(tpg_new, ip, 3260, mode='any') def test_create_rtslib_error_network_portal_ipv4(self): - with mock.patch('sys.stdout', new=six.StringIO()): + with mock.patch('sys.stdout', new=io.StringIO()): self._test_create_rtslib_error_network_portal('0.0.0.0') def test_create_rtslib_error_network_portal_ipv6(self): - with mock.patch('sys.stdout', new=six.StringIO()): + with mock.patch('sys.stdout', new=io.StringIO()): self._test_create_rtslib_error_network_portal('::0') def _test_create(self, ip): @@ -1371,7 +1370,7 @@ class TestCinderRtstoolCmd(test.TestCase): def test_add_initiator_rtslib_error(self, rtsroot): rtsroot.side_effect = rtslib_fb.utils.RTSLibError() - with mock.patch('sys.stdout', new=six.StringIO()): + with mock.patch('sys.stdout', new=io.StringIO()): self.assertRaises(rtslib_fb.utils.RTSLibError, cinder_rtstool.add_initiator, mock.sentinel.target_iqn, @@ -1490,7 +1489,7 @@ class TestCinderRtstoolCmd(test.TestCase): target.dump.return_value = {'wwn': 'fake-wwn'} rtsroot.return_value = mock.MagicMock(targets=[target]) - with mock.patch('sys.stdout', new=six.StringIO()) as fake_out: + with mock.patch('sys.stdout', new=io.StringIO()) as fake_out: cinder_rtstool.get_targets() self.assertEqual(str(target.wwn), fake_out.getvalue().strip()) @@ -1635,7 +1634,7 @@ class TestCinderRtstoolCmd(test.TestCase): mock.sentinel.filename) def test_usage(self): - with mock.patch('sys.stdout', new=six.StringIO()): + with mock.patch('sys.stdout', new=io.StringIO()): exit = self.assertRaises(SystemExit, cinder_rtstool.usage) self.assertEqual(1, exit.code) diff --git a/cinder/tests/unit/test_db_api.py b/cinder/tests/unit/test_db_api.py index 7788cd57cdd..d1bd63031a0 100644 --- a/cinder/tests/unit/test_db_api.py +++ b/cinder/tests/unit/test_db_api.py @@ -22,7 +22,6 @@ import ddt from oslo_config import cfg from oslo_utils import timeutils from oslo_utils import uuidutils -import six from sqlalchemy.sql import operators from cinder.api import common @@ -1731,7 +1730,7 @@ class DBAPISnapshotTestCase(BaseTest): snapshot = db.snapshot_get_latest_for_volume(self.ctxt, 1) - self.assertEqual(six.text_type(latest), snapshot['id']) + self.assertEqual(str(latest), snapshot['id']) def test_snapshot_get_latest_for_volume_not_found(self): diff --git a/cinder/tests/unit/test_db_worker_api.py b/cinder/tests/unit/test_db_worker_api.py index 5045eadd265..62220baa0fc 100644 --- a/cinder/tests/unit/test_db_worker_api.py +++ b/cinder/tests/unit/test_db_worker_api.py @@ -21,7 +21,6 @@ from unittest import mock import uuid from oslo_db import exception as db_exception -import six from cinder import context from cinder import db @@ -36,7 +35,7 @@ class DBAPIWorkerTestCase(test.TestCase, test.ModelsObjectComparatorMixin): 'status': 'creating'} def _uuid(self): - return six.text_type(uuid.uuid4()) + return str(uuid.uuid4()) def setUp(self): super(DBAPIWorkerTestCase, self).setUp() diff --git a/cinder/tests/unit/test_exception.py b/cinder/tests/unit/test_exception.py index 155808b123a..4c37e0461f2 100644 --- a/cinder/tests/unit/test_exception.py +++ b/cinder/tests/unit/test_exception.py @@ -15,12 +15,10 @@ # License for the specific language governing permissions and limitations # under the License. -import sys +from http import client as http_client from unittest import mock import fixtures -import six -from six.moves import http_client import webob.util from cinder import exception @@ -36,9 +34,8 @@ class CinderExceptionReraiseFormatError(object): @staticmethod def _wrap_log_exception(self): - exc_info = sys.exc_info() CinderExceptionReraiseFormatError.real_log_exception(self) - six.reraise(*exc_info) + raise # NOTE(melwitt) This needs to be done at import time in order to also catch @@ -53,18 +50,17 @@ class CinderExceptionTestCase(test.TestCase): message = "default message" exc = FakeCinderException() - self.assertEqual('default message', six.text_type(exc)) + self.assertEqual('default message', str(exc)) def test_error_msg(self): - self.assertEqual('test', - six.text_type(exception.CinderException('test'))) + self.assertEqual('test', str(exception.CinderException('test'))) def test_default_error_msg_with_kwargs(self): class FakeCinderException(exception.CinderException): message = "default message: %(code)s" exc = FakeCinderException(code=int(http_client.INTERNAL_SERVER_ERROR)) - self.assertEqual('default message: 500', six.text_type(exc)) + self.assertEqual('default message: 500', str(exc)) def test_error_msg_exception_with_kwargs(self): # NOTE(dprince): disable format errors for this test @@ -76,8 +72,7 @@ class CinderExceptionTestCase(test.TestCase): message = "default message: %(misspelled_code)s" exc = FakeCinderException(code=http_client.INTERNAL_SERVER_ERROR) - self.assertEqual('default message: %(misspelled_code)s', - six.text_type(exc)) + self.assertEqual('default message: %(misspelled_code)s', str(exc)) def test_default_error_code(self): class FakeCinderException(exception.CinderException): @@ -110,7 +105,7 @@ class CinderExceptionTestCase(test.TestCase): message = 'FakeCinderException: %(message)s' exc = FakeCinderException(message='message') - self.assertEqual('FakeCinderException: message', six.text_type(exc)) + self.assertEqual('FakeCinderException: message', str(exc)) def test_message_and_kwarg_in_format_string(self): class FakeCinderException(exception.CinderException): @@ -118,7 +113,7 @@ class CinderExceptionTestCase(test.TestCase): exc = FakeCinderException(message='message', code=http_client.NOT_FOUND) - self.assertEqual('Error 404: message', six.text_type(exc)) + self.assertEqual('Error 404: message', str(exc)) def test_message_is_exception_in_format_string(self): class FakeCinderException(exception.CinderException): @@ -127,7 +122,7 @@ class CinderExceptionTestCase(test.TestCase): msg = 'test message' exc1 = Exception(msg) exc2 = FakeCinderException(message=exc1) - self.assertEqual('Exception: test message', six.text_type(exc2)) + self.assertEqual('Exception: test message', str(exc2)) class CinderConvertedExceptionTestCase(test.TestCase): diff --git a/cinder/tests/unit/test_manager.py b/cinder/tests/unit/test_manager.py index 5dbb0cdf239..1a0a244708f 100644 --- a/cinder/tests/unit/test_manager.py +++ b/cinder/tests/unit/test_manager.py @@ -15,8 +15,6 @@ from unittest import mock -import six - from cinder import manager from cinder import objects from cinder.tests.unit import test @@ -54,5 +52,5 @@ class TestManager(test.TestCase): expected = (objects.LogLevel(prefix='cinder', level='DEBUG'), objects.LogLevel(prefix='cinder.api', level='ERROR')) - self.assertEqual(set(six.text_type(r) for r in result.objects), - set(six.text_type(e) for e in expected)) + self.assertEqual(set(str(r) for r in result.objects), + set(str(e) for e in expected)) diff --git a/cinder/tests/unit/test_qos_specs.py b/cinder/tests/unit/test_qos_specs.py index 4e18f466739..7d42fd9bba8 100644 --- a/cinder/tests/unit/test_qos_specs.py +++ b/cinder/tests/unit/test_qos_specs.py @@ -20,7 +20,6 @@ from unittest import mock from oslo_db import exception as db_exc from oslo_utils import timeutils -import six from cinder import context from cinder import db @@ -42,7 +41,7 @@ def fake_db_qos_specs_create(context, values): def fake_db_get_vol_type(vol_type_number=1): - return {'name': 'type-' + six.text_type(vol_type_number), + return {'name': 'type-' + str(vol_type_number), 'id': fake.QOS_SPEC_ID, 'updated_at': None, 'created_at': None, diff --git a/cinder/tests/unit/test_quota.py b/cinder/tests/unit/test_quota.py index 5df538fab16..69feb0eb594 100644 --- a/cinder/tests/unit/test_quota.py +++ b/cinder/tests/unit/test_quota.py @@ -21,7 +21,6 @@ from unittest import mock from oslo_config import cfg from oslo_config import fixture as config_fixture from oslo_utils import timeutils -import six from cinder import backup from cinder.backup import api as backup_api @@ -131,7 +130,7 @@ class QuotaIntegrationTestCase(test.TestCase): volume_type=self.volume_type) msg = ("Maximum number of volumes allowed (%d) exceeded for" " quota 'volumes'." % CONF.quota_volumes) - self.assertEqual(msg, six.text_type(ex)) + self.assertEqual(msg, str(ex)) for volume_id in volume_ids: db.volume_destroy(self.context, volume_id) @@ -150,7 +149,7 @@ class QuotaIntegrationTestCase(test.TestCase): volume_type=self.volume_type) msg = ("Maximum number of volumes allowed (1) exceeded for" " quota '%s'." % resource) - self.assertEqual(msg, six.text_type(ex)) + self.assertEqual(msg, str(ex)) vol_ref.destroy() def test__snapshots_quota_value(self): diff --git a/cinder/tests/unit/test_utils.py b/cinder/tests/unit/test_utils.py index 4069c7e9525..116ba9b59b2 100644 --- a/cinder/tests/unit/test_utils.py +++ b/cinder/tests/unit/test_utils.py @@ -22,7 +22,6 @@ from unittest import mock import ddt from oslo_utils import timeutils -import six import webob.exc import cinder @@ -1308,8 +1307,7 @@ class LogTracingTestCase(test.TestCase): utils.setup_tracing(['method']) - @six.add_metaclass(utils.TraceWrapperMetaclass) - class MyClass(object): + class MyClass(object, metaclass=utils.TraceWrapperMetaclass): def trace_test_method(self): return 'OK' diff --git a/cinder/tests/unit/test_volume_utils.py b/cinder/tests/unit/test_volume_utils.py index 307f6496601..504171da8f8 100644 --- a/cinder/tests/unit/test_volume_utils.py +++ b/cinder/tests/unit/test_volume_utils.py @@ -25,7 +25,6 @@ import ddt from oslo_concurrency import processutils from oslo_config import cfg from oslo_utils import units -import six from cinder import context from cinder import db @@ -168,8 +167,8 @@ class NotifyUsageTestCase(test.TestCase): 'created_at': '2014-12-11T10:10:00+00:00', 'status': fields.SnapshotStatus.ERROR, 'deleted': '', - 'metadata': six.text_type({'fake_snap_meta_key': - u'fake_snap_meta_value'}), + 'metadata': str({'fake_snap_meta_key': + u'fake_snap_meta_value'}), } self.assertDictEqual(expected_snapshot, usage_info) @@ -213,8 +212,8 @@ class NotifyUsageTestCase(test.TestCase): 'created_at': mock.ANY, 'status': fields.SnapshotStatus.ERROR, 'deleted': '', - 'metadata': six.text_type({'fake_snap_meta_key': - u'fake_snap_meta_value'}), + 'metadata': str({'fake_snap_meta_key': + u'fake_snap_meta_value'}), } self.assertDictEqual(expected_snapshot, usage_info) @@ -1093,7 +1092,7 @@ class VolumeUtilsTestCase(test.TestCase): image_meta, vol_size) self.assertIn("Volume size 2GB cannot be smaller than the image " - "minDisk size 3GB.", six.text_type(res)) + "minDisk size 3GB.", str(res)) image_meta['size'] = 3 * units.Gi res = self.assertRaises(exception.InvalidInput, @@ -1101,14 +1100,14 @@ class VolumeUtilsTestCase(test.TestCase): image_meta, vol_size) self.assertIn("Size of specified image 3GB is larger than volume " - "size 2GB.", six.text_type(res)) + "size 2GB.", str(res)) image_meta['status'] = 'error' res = self.assertRaises(exception.InvalidInput, volume_utils.check_image_metadata, image_meta, vol_size) - self.assertIn("Image 1 is not active.", six.text_type(res)) + self.assertIn("Image 1 is not active.", str(res)) def test_enable_volume_bootable(self): ctxt = context.get_admin_context() diff --git a/cinder/tests/unit/utils.py b/cinder/tests/unit/utils.py index a870bececa5..f4ed2771ece 100644 --- a/cinder/tests/unit/utils.py +++ b/cinder/tests/unit/utils.py @@ -14,6 +14,7 @@ # import datetime +import functools import socket from unittest import mock import uuid @@ -23,7 +24,6 @@ from oslo_config import cfg from oslo_service import loopingcall from oslo_utils import timeutils import oslo_versionedobjects -import six from cinder.common import constants from cinder import context @@ -544,7 +544,7 @@ def set_timeout(timeout): def _decorator(f): - @six.wraps(f) + @functools.wraps(f) def _wrapper(self, *args, **kwargs): self.useFixture(fixtures.Timeout(timeout, gentle=True)) return f(self, *args, **kwargs)