diff options
author | Takashi Natsume <takanattie@gmail.com> | 2020-05-14 15:01:28 +0000 |
---|---|---|
committer | Takashi Natsume <takanattie@gmail.com> | 2020-12-13 11:26:35 +0000 |
commit | 1cf2431f4bf815fc828a7878bd80f5f5bd8e8319 (patch) | |
tree | d493731db6a3bca4d6d7becb8f5cee594ce767be /nova/tests/unit/objects | |
parent | 383e2a8bdcc9210cbe9719d3470fe15b787d46b0 (diff) | |
download | nova-1cf2431f4bf815fc828a7878bd80f5f5bd8e8319.tar.gz |
Remove six.text_type (2/2)
Replace six.text_type with str.
This patch completes six removal.
Change-Id: I779bd1446dc1f070fa5100ccccda7881fa508d79
Implements: blueprint six-removal
Signed-off-by: Takashi Natsume <takanattie@gmail.com>
Diffstat (limited to 'nova/tests/unit/objects')
-rw-r--r-- | nova/tests/unit/objects/test_host_mapping.py | 5 | ||||
-rw-r--r-- | nova/tests/unit/objects/test_image_meta.py | 3 | ||||
-rw-r--r-- | nova/tests/unit/objects/test_instance.py | 3 | ||||
-rw-r--r-- | nova/tests/unit/objects/test_instance_action.py | 10 | ||||
-rw-r--r-- | nova/tests/unit/objects/test_objects.py | 15 | ||||
-rw-r--r-- | nova/tests/unit/objects/test_resource.py | 4 | ||||
-rw-r--r-- | nova/tests/unit/objects/test_service.py | 3 |
7 files changed, 17 insertions, 26 deletions
diff --git a/nova/tests/unit/objects/test_host_mapping.py b/nova/tests/unit/objects/test_host_mapping.py index 7cbd9ae9c9..8917e318af 100644 --- a/nova/tests/unit/objects/test_host_mapping.py +++ b/nova/tests/unit/objects/test_host_mapping.py @@ -13,7 +13,6 @@ import mock from oslo_db import exception as db_exc from oslo_utils.fixture import uuidsentinel as uuids -import six from nova import context from nova import exception @@ -330,7 +329,7 @@ Found 1 unmapped computes in cell: %(cell)s""" % {'cell': uuids.cell1} exp = self.assertRaises(exception.HostMappingExists, host_mapping.discover_hosts, ctxt) expected = "Host 'bar' mapping already exists" - self.assertIn(expected, six.text_type(exp)) + self.assertIn(expected, str(exp)) @mock.patch('nova.objects.CellMappingList.get_all') @mock.patch('nova.objects.HostMapping.get_by_host') @@ -349,4 +348,4 @@ Found 1 unmapped computes in cell: %(cell)s""" % {'cell': uuids.cell1} host_mapping.discover_hosts, ctxt, by_service=True) expected = "Host 'bar' mapping already exists" - self.assertIn(expected, six.text_type(exp)) + self.assertIn(expected, str(exp)) diff --git a/nova/tests/unit/objects/test_image_meta.py b/nova/tests/unit/objects/test_image_meta.py index 3cbb8e925d..445fe8b9c8 100644 --- a/nova/tests/unit/objects/test_image_meta.py +++ b/nova/tests/unit/objects/test_image_meta.py @@ -13,7 +13,6 @@ # under the License. import datetime -import six from nova import exception from nova import objects @@ -373,7 +372,7 @@ class TestImageMetaProps(test.NoDBTestCase): obj = objects.ImageMetaProps(hw_video_model=model) ex = self.assertRaises(exception.ObjectActionError, obj.obj_to_primitive, '1.21') - self.assertIn('hw_video_model', six.text_type(ex)) + self.assertIn('hw_video_model', str(ex)) def test_obj_make_compatible_watchdog_action_not_disabled(self): """Tests that we don't pop the hw_watchdog_action if the value is not diff --git a/nova/tests/unit/objects/test_instance.py b/nova/tests/unit/objects/test_instance.py index 63e82eab5a..53f3ea415f 100644 --- a/nova/tests/unit/objects/test_instance.py +++ b/nova/tests/unit/objects/test_instance.py @@ -14,7 +14,6 @@ import collections import datetime -import six import mock import netaddr @@ -1210,7 +1209,7 @@ class _TestInstanceObject(object): inst.host = None ex = self.assertRaises(exception.ObjectActionError, inst.destroy, hard_delete=True) - self.assertIn('host changed', six.text_type(ex)) + self.assertIn('host changed', str(ex)) def test_name_does_not_trigger_lazy_loads(self): values = {'user_id': self.context.user_id, diff --git a/nova/tests/unit/objects/test_instance_action.py b/nova/tests/unit/objects/test_instance_action.py index 6576f60b99..aa9fc20025 100644 --- a/nova/tests/unit/objects/test_instance_action.py +++ b/nova/tests/unit/objects/test_instance_action.py @@ -19,7 +19,6 @@ import mock from oslo_utils import fixture as utils_fixture from oslo_utils.fixture import uuidsentinel as uuids from oslo_utils import timeutils -import six from nova.db import api as db from nova import exception @@ -187,7 +186,7 @@ class _TestInstanceActionObject(object): def test_create_id_in_updates_error(self): action = instance_action.InstanceAction(self.context, id=1) ex = self.assertRaises(exception.ObjectActionError, action.create) - self.assertIn('already created', six.text_type(ex)) + self.assertIn('already created', str(ex)) @mock.patch('nova.db.api.action_start') def test_create(self, mock_action_start): @@ -335,14 +334,13 @@ class _TestInstanceActionEventObject(object): self.useFixture(utils_fixture.TimeFixture(NOW)) test_class = instance_action.InstanceActionEvent expected_packed_values = test_class.pack_action_event_finish( - self.context, 'fake-uuid', 'fake-event', 'val', - six.text_type('fake-tb')) + self.context, 'fake-uuid', 'fake-event', 'val', 'fake-tb') expected_packed_values['finish_time'] = NOW mock_finish.return_value = fake_event event = test_class.event_finish_with_failure( self.context, 'fake-uuid', 'fake-event', exc_val='val', - exc_tb=six.text_type('fake-tb'), want_result=True) + exc_tb='fake-tb', want_result=True) mock_finish.assert_called_once_with(self.context, expected_packed_values) self.compare_obj(event, fake_event) @@ -404,7 +402,7 @@ class _TestInstanceActionEventObject(object): ex = self.assertRaises( exception.ObjectActionError, event.create, fake_action['instance_uuid'], fake_action['request_id']) - self.assertIn('already created', six.text_type(ex)) + self.assertIn('already created', str(ex)) @mock.patch('nova.db.api.action_event_start') def test_create(self, mock_action_event_start): diff --git a/nova/tests/unit/objects/test_objects.py b/nova/tests/unit/objects/test_objects.py index e19f7c7bd0..a0fe7b9e98 100644 --- a/nova/tests/unit/objects/test_objects.py +++ b/nova/tests/unit/objects/test_objects.py @@ -25,7 +25,6 @@ from oslo_utils import timeutils from oslo_versionedobjects import base as ovo_base from oslo_versionedobjects import exception as ovo_exc from oslo_versionedobjects import fixture -import six from nova import context from nova import exception @@ -257,7 +256,7 @@ class FakeIndirectionHack(fixture.FakeIndirectionAPI): objinst = self._ser.deserialize_entity( context, self._ser.serialize_entity( context, objinst)) - objmethod = six.text_type(objmethod) + objmethod = str(objmethod) args = self._ser.deserialize_entity( None, self._ser.serialize_entity(None, args)) kwargs = self._ser.deserialize_entity( @@ -272,9 +271,9 @@ class FakeIndirectionHack(fixture.FakeIndirectionAPI): def object_class_action(self, context, objname, objmethod, objver, args, kwargs): - objname = six.text_type(objname) - objmethod = six.text_type(objmethod) - objver = six.text_type(objver) + objname = str(objname) + objmethod = str(objmethod) + objver = str(objver) args = self._ser.deserialize_entity( None, self._ser.serialize_entity(None, args)) kwargs = self._ser.deserialize_entity( @@ -292,9 +291,9 @@ class FakeIndirectionHack(fixture.FakeIndirectionAPI): def object_class_action_versions(self, context, objname, objmethod, object_versions, args, kwargs): - objname = six.text_type(objname) - objmethod = six.text_type(objmethod) - object_versions = {six.text_type(o): six.text_type(v) + objname = str(objname) + objmethod = str(objmethod) + object_versions = {str(o): str(v) for o, v in object_versions.items()} args, kwargs = self._canonicalize_args(context, args, kwargs) objver = object_versions[objname] diff --git a/nova/tests/unit/objects/test_resource.py b/nova/tests/unit/objects/test_resource.py index 966d9c6d20..892562f11d 100644 --- a/nova/tests/unit/objects/test_resource.py +++ b/nova/tests/unit/objects/test_resource.py @@ -13,7 +13,6 @@ import mock from oslo_serialization import jsonutils from oslo_utils.fixture import uuidsentinel as uuids -import six from nova.objects import resource from nova.tests.unit.objects import test_objects @@ -53,8 +52,7 @@ class TestResourceObject(test_objects._LocalTest): resource_class=rc, identifier='foo') except ValueError as e: - self.assertEqual('Malformed Resource Class %s' % rc, - six.text_type(e)) + self.assertEqual('Malformed Resource Class %s' % rc, str(e)) else: self.fail('Check malformed resource class failed.') diff --git a/nova/tests/unit/objects/test_service.py b/nova/tests/unit/objects/test_service.py index de4d96d53f..e5ad835ff9 100644 --- a/nova/tests/unit/objects/test_service.py +++ b/nova/tests/unit/objects/test_service.py @@ -17,7 +17,6 @@ from oslo_utils.fixture import uuidsentinel from oslo_utils import timeutils from oslo_versionedobjects import base as ovo_base from oslo_versionedobjects import exception as ovo_exc -import six from nova.compute import manager as compute_manager from nova import context @@ -530,7 +529,7 @@ class TestServiceVersionCells(test.TestCase): ex = self.assertRaises(exception.ObjectActionError, service.get_minimum_version_all_cells, self.context, ['compute']) - self.assertIn('Invalid binary prefix', six.text_type(ex)) + self.assertIn('Invalid binary prefix', str(ex)) self.assertTrue(mock_log.warning.called) @mock.patch('nova.context.scatter_gather_all_cells') |