summaryrefslogtreecommitdiff
path: root/nova/tests/unit/api
diff options
context:
space:
mode:
Diffstat (limited to 'nova/tests/unit/api')
-rw-r--r--nova/tests/unit/api/openstack/compute/test_admin_password.py4
-rw-r--r--nova/tests/unit/api/openstack/compute/test_attach_interfaces.py3
-rw-r--r--nova/tests/unit/api/openstack/compute/test_baremetal_nodes.py3
-rw-r--r--nova/tests/unit/api/openstack/compute/test_create_backup.py3
-rw-r--r--nova/tests/unit/api/openstack/compute/test_evacuate.py3
-rw-r--r--nova/tests/unit/api/openstack/compute/test_flavor_manage.py7
-rw-r--r--nova/tests/unit/api/openstack/compute/test_hypervisors.py9
-rw-r--r--nova/tests/unit/api/openstack/compute/test_instance_actions.py15
-rw-r--r--nova/tests/unit/api/openstack/compute/test_lock_server.py7
-rw-r--r--nova/tests/unit/api/openstack/compute/test_migrate_server.py7
-rw-r--r--nova/tests/unit/api/openstack/compute/test_migrations.py17
-rw-r--r--nova/tests/unit/api/openstack/compute/test_server_external_events.py4
-rw-r--r--nova/tests/unit/api/openstack/compute/test_server_groups.py12
-rw-r--r--nova/tests/unit/api/openstack/compute/test_server_start_stop.py5
-rw-r--r--nova/tests/unit/api/openstack/compute/test_servers.py100
-rw-r--r--nova/tests/unit/api/openstack/compute/test_services.py13
-rw-r--r--nova/tests/unit/api/openstack/compute/test_shelve.py7
-rw-r--r--nova/tests/unit/api/openstack/compute/test_suspend_server.py3
-rw-r--r--nova/tests/unit/api/openstack/compute/test_volumes.py33
-rw-r--r--nova/tests/unit/api/openstack/test_common.py3
20 files changed, 105 insertions, 153 deletions
diff --git a/nova/tests/unit/api/openstack/compute/test_admin_password.py b/nova/tests/unit/api/openstack/compute/test_admin_password.py
index 48049c7361..90a4a2983b 100644
--- a/nova/tests/unit/api/openstack/compute/test_admin_password.py
+++ b/nova/tests/unit/api/openstack/compute/test_admin_password.py
@@ -14,7 +14,6 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
-import six
import webob
from nova.api.openstack.compute import admin_password as admin_password_v21
@@ -126,8 +125,7 @@ class AdminPasswordTestV21(test.NoDBTestCase):
ex = self.assertRaises(self.validation_error,
self._get_action(),
self.fake_req, fakes.FAKE_UUID, body=body)
- self.assertIn('adminPass. Value: None. None is not of type',
- six.text_type(ex))
+ self.assertIn('adminPass. Value: None. None is not of type', str(ex))
def test_change_password_adminpass_none(self):
body = {'changePassword': None}
diff --git a/nova/tests/unit/api/openstack/compute/test_attach_interfaces.py b/nova/tests/unit/api/openstack/compute/test_attach_interfaces.py
index da917d4118..26ebab0bea 100644
--- a/nova/tests/unit/api/openstack/compute/test_attach_interfaces.py
+++ b/nova/tests/unit/api/openstack/compute/test_attach_interfaces.py
@@ -14,7 +14,6 @@
# under the License.
import mock
-import six
from webob import exc
from nova.api.openstack import common
@@ -325,7 +324,7 @@ class InterfaceAttachTestsV21(test.NoDBTestCase):
ex = self.assertRaises(
exc.HTTPForbidden, self.attachments.create,
self.req, FAKE_UUID1, body=body)
- self.assertIn('Maximum number of ports exceeded', six.text_type(ex))
+ self.assertIn('Maximum number of ports exceeded', str(ex))
def test_detach_interface_with_invalid_state(self):
def fake_detach_interface_invalid_state(*args, **kwargs):
diff --git a/nova/tests/unit/api/openstack/compute/test_baremetal_nodes.py b/nova/tests/unit/api/openstack/compute/test_baremetal_nodes.py
index 8a3b66162d..55a8b03216 100644
--- a/nova/tests/unit/api/openstack/compute/test_baremetal_nodes.py
+++ b/nova/tests/unit/api/openstack/compute/test_baremetal_nodes.py
@@ -16,7 +16,6 @@
from ironicclient import exc as ironic_exc
import mock
-import six
from webob import exc
from nova.api.openstack.compute import baremetal_nodes \
@@ -181,7 +180,7 @@ class BareMetalNodesTestV21(test.NoDBTestCase):
def test_show_ironic_node_not_found(self, mock_get):
error = self.assertRaises(exc.HTTPNotFound, self.controller.show,
self.request, 'fake-uuid')
- self.assertIn('fake-uuid', six.text_type(error))
+ self.assertIn('fake-uuid', str(error))
def test_show_ironic_not_implemented(self):
with mock.patch.object(self.mod, 'ironic_client', None):
diff --git a/nova/tests/unit/api/openstack/compute/test_create_backup.py b/nova/tests/unit/api/openstack/compute/test_create_backup.py
index afb4c4811f..f7280a5a37 100644
--- a/nova/tests/unit/api/openstack/compute/test_create_backup.py
+++ b/nova/tests/unit/api/openstack/compute/test_create_backup.py
@@ -15,7 +15,6 @@
import mock
from oslo_utils import timeutils
-import six
import webob
from nova.api.openstack import common
@@ -393,7 +392,7 @@ class CreateBackupTestsV21(admin_only_action_common.CommonMixin,
mock_check_image.assert_called_once_with(self.context, {})
mock_is_volume_backed.assert_called_once_with(self.context, instance)
self.assertIn('Backup is not supported for volume-backed instances',
- six.text_type(ex))
+ str(ex))
class CreateBackupTestsV239(test.NoDBTestCase):
diff --git a/nova/tests/unit/api/openstack/compute/test_evacuate.py b/nova/tests/unit/api/openstack/compute/test_evacuate.py
index bf74e55db7..a9a55965a7 100644
--- a/nova/tests/unit/api/openstack/compute/test_evacuate.py
+++ b/nova/tests/unit/api/openstack/compute/test_evacuate.py
@@ -15,7 +15,6 @@
import fixtures
import mock
from oslo_utils.fixture import uuidsentinel as uuids
-import six
import testtools
import webob
@@ -390,7 +389,7 @@ class EvacuateTestV268(EvacuateTestV229):
ex = self._check_evacuate_failure(self.validation_error,
{'host': 'my-host',
'force': 'true'})
- self.assertIn('force', six.text_type(ex))
+ self.assertIn('force', str(ex))
def test_forced_evacuate_with_no_host_provided(self):
# not applicable for v2.68, which removed the 'force' parameter
diff --git a/nova/tests/unit/api/openstack/compute/test_flavor_manage.py b/nova/tests/unit/api/openstack/compute/test_flavor_manage.py
index 5950a9b230..e6e1c8e26a 100644
--- a/nova/tests/unit/api/openstack/compute/test_flavor_manage.py
+++ b/nova/tests/unit/api/openstack/compute/test_flavor_manage.py
@@ -17,7 +17,6 @@ import copy
import mock
from oslo_serialization import jsonutils
-import six
import webob
from nova.api.openstack.compute import flavor_access as flavor_access_v21
@@ -74,7 +73,7 @@ class FlavorManageTestV21(test.NoDBTestCase):
"vcpus": 2,
"disk": 1,
"OS-FLV-EXT-DATA:ephemeral": 1,
- "id": six.text_type('1234'),
+ "id": '1234',
"swap": 512,
"rxtx_factor": 1,
"os-flavor-access:is_public": True,
@@ -117,7 +116,7 @@ class FlavorManageTestV21(test.NoDBTestCase):
"vcpus": 2,
"disk": 1,
"OS-FLV-EXT-DATA:ephemeral": 1,
- "id": six.text_type('1234'),
+ "id": '1234',
"swap": 512,
"rxtx_factor": 1,
"os-flavor-access:is_public": True,
@@ -343,7 +342,7 @@ class FlavorManageTestV21(test.NoDBTestCase):
ex = self.assertRaises(
self.validation_error, self.controller._create,
self._get_http_request(), body=self.request_body)
- self.assertIn('description', six.text_type(ex))
+ self.assertIn('description', str(ex))
def test_flavor_update_description(self):
"""With microversion <2.55 this should return a failure."""
diff --git a/nova/tests/unit/api/openstack/compute/test_hypervisors.py b/nova/tests/unit/api/openstack/compute/test_hypervisors.py
index 4a153b7a36..95fc822326 100644
--- a/nova/tests/unit/api/openstack/compute/test_hypervisors.py
+++ b/nova/tests/unit/api/openstack/compute/test_hypervisors.py
@@ -19,7 +19,6 @@ import mock
import netaddr
from oslo_serialization import jsonutils
from oslo_utils.fixture import uuidsentinel as uuids
-import six
from webob import exc
from nova.api.openstack.compute import hypervisors \
@@ -1024,7 +1023,7 @@ class HypervisorsTestV253(HypervisorsTestV252):
ex = self.assertRaises(exc.HTTPBadRequest, self.controller.index, req)
self.assertIn('Paging over hypervisors with the '
'hypervisor_hostname_pattern query parameter is not '
- 'supported.', six.text_type(ex))
+ 'supported.', str(ex))
def test_servers_with_non_integer_hypervisor_id(self):
"""This is a poorly named test, it's really checking the 404 case where
@@ -1134,7 +1133,7 @@ class HypervisorsTestV253(HypervisorsTestV252):
req = self._get_request(True)
ex = self.assertRaises(exc.HTTPBadRequest,
self.controller.show, req, '1')
- self.assertIn('Invalid uuid 1', six.text_type(ex))
+ self.assertIn('Invalid uuid 1', str(ex))
def test_show_with_servers_invalid_parameter(self):
"""Tests passing an invalid value for the with_servers query parameter
@@ -1146,7 +1145,7 @@ class HypervisorsTestV253(HypervisorsTestV252):
url='/os-hypervisors/%s?with_servers=invalid' % hyper_id)
ex = self.assertRaises(
exception.ValidationError, self.controller.show, req, hyper_id)
- self.assertIn('with_servers', six.text_type(ex))
+ self.assertIn('with_servers', str(ex))
def test_show_with_servers_host_mapping_not_found(self):
"""Tests that a 404 is returned if instance_get_all_by_host raises
@@ -1195,7 +1194,7 @@ class HypervisorsTestV253(HypervisorsTestV252):
req = self._get_request(True)
ex = self.assertRaises(exc.HTTPBadRequest,
self.controller.uptime, req, '1')
- self.assertIn('Invalid uuid 1', six.text_type(ex))
+ self.assertIn('Invalid uuid 1', str(ex))
def test_detail_pagination(self):
"""Tests details paging with uuid markers."""
diff --git a/nova/tests/unit/api/openstack/compute/test_instance_actions.py b/nova/tests/unit/api/openstack/compute/test_instance_actions.py
index 503ab1f6c1..fc6fd0d211 100644
--- a/nova/tests/unit/api/openstack/compute/test_instance_actions.py
+++ b/nova/tests/unit/api/openstack/compute/test_instance_actions.py
@@ -20,7 +20,6 @@ import iso8601
import mock
from oslo_policy import policy as oslo_policy
from oslo_utils.fixture import uuidsentinel as uuids
-import six
from webob import exc
from nova.api.openstack.compute import instance_actions as instance_actions_v21
@@ -273,7 +272,7 @@ class InstanceActionsTestV258(InstanceActionsTestV251):
ex = self.assertRaises(exception.ValidationError,
self.controller.index, req)
self.assertIn('Invalid input for query parameters changes-since',
- six.text_type(ex))
+ str(ex))
def test_get_action_with_invalid_params(self):
"""Tests get paging with a invalid change_since."""
@@ -281,16 +280,14 @@ class InstanceActionsTestV258(InstanceActionsTestV251):
'wrong_params=xxx')
ex = self.assertRaises(exception.ValidationError,
self.controller.index, req)
- self.assertIn('Additional properties are not allowed',
- six.text_type(ex))
+ self.assertIn('Additional properties are not allowed', str(ex))
def test_get_action_with_multi_params(self):
"""Tests get paging with multi markers."""
req = self._get_http_req('os-instance-actions?marker=A&marker=B')
ex = self.assertRaises(exception.ValidationError,
self.controller.index, req)
- self.assertIn('Invalid input for query parameters marker',
- six.text_type(ex))
+ self.assertIn('Invalid input for query parameters marker', str(ex))
class InstanceActionsTestV262(InstanceActionsTestV258):
@@ -367,7 +364,7 @@ class InstanceActionsTestV266(InstanceActionsTestV258):
ex = self.assertRaises(exception.ValidationError,
self.controller.index, req)
self.assertIn('Invalid input for query parameters changes-before',
- six.text_type(ex))
+ str(ex))
@mock.patch('nova.compute.api.InstanceActionAPI.actions_get')
@mock.patch('nova.api.openstack.common.get_instance')
@@ -401,7 +398,7 @@ class InstanceActionsTestV266(InstanceActionsTestV258):
ex = self.assertRaises(exc.HTTPBadRequest, self.controller.index,
req, FAKE_UUID)
self.assertIn('The value of changes-since must be less than '
- 'or equal to changes-before', six.text_type(ex))
+ 'or equal to changes-before', str(ex))
def test_get_action_with_changes_before_old_microversion(self):
"""Tests that the changes-before query parameter is an error before
@@ -414,7 +411,7 @@ class InstanceActionsTestV266(InstanceActionsTestV258):
ex = self.assertRaises(exception.ValidationError,
self.controller.index, req)
detail = 'Additional properties are not allowed'
- self.assertIn(detail, six.text_type(ex))
+ self.assertIn(detail, str(ex))
class InstanceActionsTestV284(InstanceActionsTestV266):
diff --git a/nova/tests/unit/api/openstack/compute/test_lock_server.py b/nova/tests/unit/api/openstack/compute/test_lock_server.py
index c5bed64cc5..a605e2bcdb 100644
--- a/nova/tests/unit/api/openstack/compute/test_lock_server.py
+++ b/nova/tests/unit/api/openstack/compute/test_lock_server.py
@@ -14,7 +14,6 @@
# under the License.
import mock
-import six
from nova.api.openstack import api_version_request
from nova.api.openstack import common
@@ -103,7 +102,7 @@ class LockServerTestsV273(LockServerTestsV21):
exp = self.assertRaises(exception.ValidationError,
self.controller._lock, self.req, instance.uuid, body=body)
- self.assertIn('is too long', six.text_type(exp))
+ self.assertIn('is too long', str(exp))
def test_lock_with_reason_in_invalid_format(self):
instance = fake_instance.fake_instance_obj(
@@ -113,7 +112,7 @@ class LockServerTestsV273(LockServerTestsV21):
exp = self.assertRaises(exception.ValidationError,
self.controller._lock, self.req, instance.uuid, body=body)
- self.assertIn("256 is not of type 'string'", six.text_type(exp))
+ self.assertIn("256 is not of type 'string'", str(exp))
def test_lock_with_invalid_paramater(self):
# This will fail from 2.73 since we have a schema check that allows
@@ -124,4 +123,4 @@ class LockServerTestsV273(LockServerTestsV21):
exp = self.assertRaises(exception.ValidationError,
self.controller._lock, self.req, instance.uuid, body=body)
- self.assertIn("('blah' was unexpected)", six.text_type(exp))
+ self.assertIn("('blah' was unexpected)", str(exp))
diff --git a/nova/tests/unit/api/openstack/compute/test_migrate_server.py b/nova/tests/unit/api/openstack/compute/test_migrate_server.py
index 632b7c7cff..5928fe3e56 100644
--- a/nova/tests/unit/api/openstack/compute/test_migrate_server.py
+++ b/nova/tests/unit/api/openstack/compute/test_migrate_server.py
@@ -17,7 +17,6 @@ import fixtures
import mock
from oslo_utils.fixture import uuidsentinel as uuids
from oslo_utils import uuidutils
-import six
import webob
from nova.api.openstack import api_version_request
@@ -226,7 +225,7 @@ class MigrateServerTestsV21(admin_only_action_common.CommonTests):
self.controller._migrate_live,
self.req, instance.uuid, body=body)
if check_response:
- self.assertIn(six.text_type(fake_exc), ex.explanation)
+ self.assertIn(str(fake_exc), ex.explanation)
mock_live_migrate.assert_called_once_with(
self.context, instance, False, self.disk_over_commit,
'hostname', self.force, self.async_)
@@ -601,7 +600,7 @@ class MigrateServerTestsV268(MigrateServerTestsV256):
self.req, fakes.FAKE_UUID, body=body)
self.assertIn("Operation 'live-migration' not supported for "
"SEV-enabled instance (%s)" % instance.uuid,
- six.text_type(ex))
+ str(ex))
def test_live_migrate_with_forced_host(self):
body = {'os-migrateLive': {'host': 'hostname',
@@ -610,4 +609,4 @@ class MigrateServerTestsV268(MigrateServerTestsV256):
ex = self.assertRaises(self.validation_error,
self.controller._migrate_live,
self.req, fakes.FAKE_UUID, body=body)
- self.assertIn('force', six.text_type(ex))
+ self.assertIn('force', str(ex))
diff --git a/nova/tests/unit/api/openstack/compute/test_migrations.py b/nova/tests/unit/api/openstack/compute/test_migrations.py
index edd1197a75..a06d395bea 100644
--- a/nova/tests/unit/api/openstack/compute/test_migrations.py
+++ b/nova/tests/unit/api/openstack/compute/test_migrations.py
@@ -17,7 +17,6 @@ import datetime
import iso8601
import mock
from oslo_utils.fixture import uuidsentinel as uuids
-import six
from webob import exc
from nova.api.openstack.compute import migrations as migrations_v21
@@ -314,7 +313,7 @@ class MigrationsTestCaseV259(MigrationsTestCaseV223):
self.controller.index, req)
self.assertEqual(
"Marker %s could not be found." % uuids.invalid_marker,
- six.text_type(e))
+ str(e))
def test_index_with_invalid_limit(self):
"""Tests detail paging with an invalid limit."""
@@ -344,8 +343,7 @@ class MigrationsTestCaseV259(MigrationsTestCaseV223):
version=self.wsgi_api_version, use_admin_context=True)
ex = self.assertRaises(exception.ValidationError,
self.controller.index, req)
- self.assertIn('Additional properties are not allowed',
- six.text_type(ex))
+ self.assertIn('Additional properties are not allowed', str(ex))
@mock.patch('nova.compute.api.API.get_migrations',
return_value=objects.MigrationList())
@@ -413,7 +411,7 @@ class MigrationTestCaseV266(MigrationsTestCaseV259):
use_admin_context=True)
ex = self.assertRaises(exc.HTTPBadRequest, self.controller.index, req)
self.assertIn('The value of changes-since must be less than '
- 'or equal to changes-before', six.text_type(ex))
+ 'or equal to changes-before', str(ex))
def test_index_with_changes_before_old_microversion_failed(self):
"""Tests that the changes-before query parameter is an error before
@@ -427,8 +425,7 @@ class MigrationTestCaseV266(MigrationsTestCaseV259):
version='2.65', use_admin_context=True)
ex = self.assertRaises(exception.ValidationError,
self.controller.index, req)
- self.assertIn('Additional properties are not allowed',
- six.text_type(ex))
+ self.assertIn('Additional properties are not allowed', str(ex))
@mock.patch('nova.compute.api.API.get_migrations',
return_value=objects.MigrationList())
@@ -490,8 +487,7 @@ class MigrationsTestCaseV280(MigrationTestCaseV266):
version='2.79', use_admin_context=True)
ex = self.assertRaises(exception.ValidationError,
self.controller.index, req)
- self.assertIn('Additional properties are not allowed',
- six.text_type(ex))
+ self.assertIn('Additional properties are not allowed', str(ex))
def test_index_filter_by_project_id_pre_v280(self):
"""Tests that the migrations by project_id query parameter
@@ -502,5 +498,4 @@ class MigrationsTestCaseV280(MigrationTestCaseV266):
version='2.79', use_admin_context=True)
ex = self.assertRaises(exception.ValidationError,
self.controller.index, req)
- self.assertIn('Additional properties are not allowed',
- six.text_type(ex))
+ self.assertIn('Additional properties are not allowed', str(ex))
diff --git a/nova/tests/unit/api/openstack/compute/test_server_external_events.py b/nova/tests/unit/api/openstack/compute/test_server_external_events.py
index ce042b5442..2ca97fc6d8 100644
--- a/nova/tests/unit/api/openstack/compute/test_server_external_events.py
+++ b/nova/tests/unit/api/openstack/compute/test_server_external_events.py
@@ -15,7 +15,6 @@
import fixtures as fx
import mock
from oslo_utils.fixture import uuidsentinel as uuids
-import six
from nova.api.openstack.compute import server_external_events \
as server_external_events_v21
@@ -260,8 +259,7 @@ class ServerExternalEventsTestV276(ServerExternalEventsTestV21):
self.api.create,
req,
body=body)
- self.assertIn('Invalid input for field/attribute name.',
- six.text_type(exp))
+ self.assertIn('Invalid input for field/attribute name.', str(exp))
@mock.patch('nova.objects.InstanceMappingList.get_by_instance_uuids',
diff --git a/nova/tests/unit/api/openstack/compute/test_server_groups.py b/nova/tests/unit/api/openstack/compute/test_server_groups.py
index a5fa299858..e7626ee733 100644
--- a/nova/tests/unit/api/openstack/compute/test_server_groups.py
+++ b/nova/tests/unit/api/openstack/compute/test_server_groups.py
@@ -17,7 +17,6 @@ import copy
import mock
from oslo_utils.fixture import uuidsentinel
from oslo_utils import uuidutils
-import six
import webob
from nova.api.openstack import api_version_request as avr
@@ -139,7 +138,7 @@ class ServerGroupTestV21(test.NoDBTestCase):
req, body={'server_group': sgroup})
self.assertIn(
"Invalid input for field/attribute server_group",
- six.text_type(result)
+ str(result)
)
# 'rules' isn't an acceptable request key before 2.64
sgroup = server_group_template(rules=rules)
@@ -148,7 +147,7 @@ class ServerGroupTestV21(test.NoDBTestCase):
req, body={'server_group': sgroup})
self.assertIn(
"Invalid input for field/attribute server_group",
- six.text_type(result)
+ str(result)
)
def test_create_server_group(self):
@@ -772,8 +771,7 @@ class ServerGroupTestV264(ServerGroupTestV213):
rules={'max_server_per_host': 3})
result = self.assertRaises(webob.exc.HTTPBadRequest,
self.controller.create, req, body={'server_group': sgroup})
- self.assertIn("Only anti-affinity policy supports rules",
- six.text_type(result))
+ self.assertIn("Only anti-affinity policy supports rules", str(result))
def test_create_anti_affinity_server_group_with_invalid_rules(self):
req = fakes.HTTPRequest.blank('', version=self.wsgi_api_version)
@@ -789,7 +787,7 @@ class ServerGroupTestV264(ServerGroupTestV213):
self.validation_error, self.controller.create,
req, body={'server_group': sgroup})
self.assertIn(
- "Invalid input for field/attribute", six.text_type(result)
+ "Invalid input for field/attribute", str(result)
)
@mock.patch('nova.objects.service.get_minimum_version_all_cells',
@@ -804,7 +802,7 @@ class ServerGroupTestV264(ServerGroupTestV213):
self.controller.create, req, body={'server_group': sgroup})
self.assertIn("Creating an anti-affinity group with rule "
"max_server_per_host > 1 is not yet supported.",
- six.text_type(result))
+ str(result))
def test_create_server_group(self):
policies = ['affinity', 'anti-affinity']
diff --git a/nova/tests/unit/api/openstack/compute/test_server_start_stop.py b/nova/tests/unit/api/openstack/compute/test_server_start_stop.py
index f3d8ba72bc..eb7be448f5 100644
--- a/nova/tests/unit/api/openstack/compute/test_server_start_stop.py
+++ b/nova/tests/unit/api/openstack/compute/test_server_start_stop.py
@@ -15,7 +15,6 @@
import mock
from oslo_policy import policy as oslo_policy
from oslo_utils.fixture import uuidsentinel as uuids
-import six
import webob
from nova.api.openstack.compute import servers \
@@ -72,7 +71,7 @@ class ServerStartStopTestV21(test.TestCase):
body = dict(start="")
ex = self.assertRaises(webob.exc.HTTPConflict,
self.controller._start_server, self.req, uuids.instance, body)
- self.assertIn('is locked', six.text_type(ex))
+ self.assertIn('is locked', str(ex))
@mock.patch.object(compute_api.API, 'stop')
def test_stop(self, stop_mock):
@@ -95,7 +94,7 @@ class ServerStartStopTestV21(test.TestCase):
body = dict(stop="")
ex = self.assertRaises(webob.exc.HTTPConflict,
self.controller._stop_server, self.req, uuids.instance, body)
- self.assertIn('is locked', six.text_type(ex))
+ self.assertIn('is locked', str(ex))
@mock.patch.object(compute_api.API, 'stop',
side_effect=exception.InstanceIsLocked(
diff --git a/nova/tests/unit/api/openstack/compute/test_servers.py b/nova/tests/unit/api/openstack/compute/test_servers.py
index 6486110d3d..b384c73f36 100644
--- a/nova/tests/unit/api/openstack/compute/test_servers.py
+++ b/nova/tests/unit/api/openstack/compute/test_servers.py
@@ -32,7 +32,6 @@ from oslo_utils import fixture as utils_fixture
from oslo_utils.fixture import uuidsentinel as uuids
from oslo_utils import timeutils
from oslo_utils import uuidutils
-import six
import testtools
import webob
@@ -311,7 +310,7 @@ class ServersControllerTest(ControllerTest):
self.controller._get_requested_networks,
requested_networks)
self.assertIn('Bad networks format: network uuid is not in proper '
- 'format', six.text_type(ex))
+ 'format', str(ex))
def test_requested_networks_enabled_with_port(self):
port = 'eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee'
@@ -2620,7 +2619,7 @@ class ServersControllerTestV273(ControllerTest):
req = self.req(self.path_with_query % 'locked=price')
exp = self.assertRaises(webob.exc.HTTPBadRequest,
self.controller.index, req)
- self.assertIn("Unrecognized value 'price'", six.text_type(exp))
+ self.assertIn("Unrecognized value 'price'", str(exp))
def test_get_servers_with_locked_filter_empty_value(self):
def fake_get_all(context, search_opts=None,
@@ -2637,7 +2636,7 @@ class ServersControllerTestV273(ControllerTest):
req = self.req(self.path_with_query % 'locked=')
exp = self.assertRaises(webob.exc.HTTPBadRequest,
self.controller.index, req)
- self.assertIn("Unrecognized value ''", six.text_type(exp))
+ self.assertIn("Unrecognized value ''", str(exp))
def test_get_servers_with_locked_sort_key(self):
def fake_get_all(context, search_opts=None,
@@ -3331,7 +3330,7 @@ class ServersControllerRebuildTestV254(ServersControllerRebuildInstanceTest):
excpt = self.assertRaises(exception.ValidationError,
self.controller._action_rebuild,
self.req, FAKE_UUID, body=body)
- self.assertIn('key_name', six.text_type(excpt))
+ self.assertIn('key_name', str(excpt))
def test_rebuild_with_not_existed_keypair_name(self):
body = {
@@ -3445,7 +3444,7 @@ class ServersControllerRebuildTestV257(ServersControllerRebuildTestV254):
ex = self.assertRaises(exception.ValidationError,
self.controller._action_rebuild,
self.req, FAKE_UUID, body=body)
- self.assertIn('personality', six.text_type(ex))
+ self.assertIn('personality', str(ex))
def test_rebuild_user_data_old_version(self):
"""Tests that trying to rebuild with user_data before 2.57 fails."""
@@ -3460,7 +3459,7 @@ class ServersControllerRebuildTestV257(ServersControllerRebuildTestV254):
ex = self.assertRaises(exception.ValidationError,
self.controller._action_rebuild,
self.req, FAKE_UUID, body=body)
- self.assertIn('user_data', six.text_type(ex))
+ self.assertIn('user_data', str(ex))
def test_rebuild_user_data_malformed(self):
"""Tests that trying to rebuild with malformed user_data fails."""
@@ -3473,7 +3472,7 @@ class ServersControllerRebuildTestV257(ServersControllerRebuildTestV254):
ex = self.assertRaises(exception.ValidationError,
self.controller._action_rebuild,
self.req, FAKE_UUID, body=body)
- self.assertIn('user_data', six.text_type(ex))
+ self.assertIn('user_data', str(ex))
def test_rebuild_user_data_too_large(self):
"""Tests that passing user_data to rebuild that is too large fails."""
@@ -3486,7 +3485,7 @@ class ServersControllerRebuildTestV257(ServersControllerRebuildTestV254):
ex = self.assertRaises(exception.ValidationError,
self.controller._action_rebuild,
self.req, FAKE_UUID, body=body)
- self.assertIn('user_data', six.text_type(ex))
+ self.assertIn('user_data', str(ex))
@mock.patch.object(context.RequestContext, 'can')
@mock.patch('nova.db.api.instance_update_and_get_original')
@@ -3660,7 +3659,7 @@ class ServersControllerRebuildTestV263(ControllerTest):
ex = self.assertRaises(exception.ValidationError,
self.controller._action_rebuild,
self.req, FAKE_UUID, body=self.body)
- self.assertIn('is too short', six.text_type(ex))
+ self.assertIn('is too short', str(ex))
def test_rebuild_server_with_empty_trusted_certs(self):
"""Make sure that we can't rebuild with an empty array of IDs"""
@@ -3669,7 +3668,7 @@ class ServersControllerRebuildTestV263(ControllerTest):
ex = self.assertRaises(exception.ValidationError,
self.controller._action_rebuild,
self.req, FAKE_UUID, body=self.body)
- self.assertIn('is too short', six.text_type(ex))
+ self.assertIn('is too short', str(ex))
def test_rebuild_server_with_too_many_trusted_certs(self):
"""Make sure that we can't rebuild with an array of >50 unique IDs"""
@@ -3679,7 +3678,7 @@ class ServersControllerRebuildTestV263(ControllerTest):
ex = self.assertRaises(exception.ValidationError,
self.controller._action_rebuild,
self.req, FAKE_UUID, body=self.body)
- self.assertIn('is too long', six.text_type(ex))
+ self.assertIn('is too long', str(ex))
def test_rebuild_server_with_nonunique_trusted_certs(self):
"""Make sure that we can't rebuild with a non-unique array of IDs"""
@@ -3688,7 +3687,7 @@ class ServersControllerRebuildTestV263(ControllerTest):
ex = self.assertRaises(exception.ValidationError,
self.controller._action_rebuild,
self.req, FAKE_UUID, body=self.body)
- self.assertIn('has non-unique elements', six.text_type(ex))
+ self.assertIn('has non-unique elements', str(ex))
def test_rebuild_server_with_invalid_trusted_cert_id(self):
"""Make sure that we can't rebuild with non-string certificate IDs"""
@@ -3697,7 +3696,7 @@ class ServersControllerRebuildTestV263(ControllerTest):
ex = self.assertRaises(exception.ValidationError,
self.controller._action_rebuild,
self.req, FAKE_UUID, body=self.body)
- self.assertIn('is not of type', six.text_type(ex))
+ self.assertIn('is not of type', str(ex))
def test_rebuild_server_with_invalid_trusted_certs(self):
"""Make sure that we can't rebuild with certificates in a non-array"""
@@ -3706,7 +3705,7 @@ class ServersControllerRebuildTestV263(ControllerTest):
ex = self.assertRaises(exception.ValidationError,
self.controller._action_rebuild,
self.req, FAKE_UUID, body=self.body)
- self.assertIn('is not of type', six.text_type(ex))
+ self.assertIn('is not of type', str(ex))
def test_rebuild_server_with_trusted_certs_pre_2_63_fails(self):
"""Make sure we can't use trusted_certs before 2.63"""
@@ -3716,8 +3715,7 @@ class ServersControllerRebuildTestV263(ControllerTest):
ex = self.assertRaises(exception.ValidationError,
self.controller._action_rebuild,
self.req, FAKE_UUID, body=self.body)
- self.assertIn('Additional properties are not allowed',
- six.text_type(ex))
+ self.assertIn('Additional properties are not allowed', str(ex))
def test_rebuild_server_with_trusted_certs_policy_failed(self):
rule_name = "os_compute_api:servers:rebuild:trusted_certs"
@@ -3740,8 +3738,7 @@ class ServersControllerRebuildTestV263(ControllerTest):
ex = self.assertRaises(webob.exc.HTTPBadRequest,
self._rebuild_server,
certs=['trusted-cert-id'])
- self.assertIn('test cert validation error',
- six.text_type(ex))
+ self.assertIn('test cert validation error', str(ex))
class ServersControllerRebuildTestV271(ControllerTest):
@@ -4335,7 +4332,7 @@ class ServersControllerCreateTest(test.TestCase):
ex = self.assertRaises(webob.exc.HTTPBadRequest,
self._test_create_instance,
flavor=1324)
- self.assertEqual('Flavor 1324 could not be found.', six.text_type(ex))
+ self.assertEqual('Flavor 1324 could not be found.', str(ex))
def test_create_server_bad_image_uuid(self):
self.body['server']['min_count'] = 1
@@ -4447,7 +4444,7 @@ class ServersControllerCreateTest(test.TestCase):
self.controller.create,
self.req, body=self.body)
# Make sure the failure was about user_data and not something else.
- self.assertIn('user_data', six.text_type(ex))
+ self.assertIn('user_data', str(ex))
@mock.patch.object(compute_api.API, 'create',
side_effect=exception.NetworkRequiresSubnet(
@@ -6343,7 +6340,7 @@ class ServersControllerCreateTest(test.TestCase):
# Tests that PciRequestAliasNotDefined is translated to a 400 error.
ex = self.assertRaises(webob.exc.HTTPBadRequest,
self._test_create_extra, {})
- self.assertIn('PCI alias fake_name is not defined', six.text_type(ex))
+ self.assertIn('PCI alias fake_name is not defined', str(ex))
@mock.patch.object(compute_api.API, 'create',
side_effect=exception.PciInvalidAlias(
@@ -6352,7 +6349,7 @@ class ServersControllerCreateTest(test.TestCase):
# Tests that PciInvalidAlias is translated to a 400 error.
ex = self.assertRaises(webob.exc.HTTPBadRequest,
self._test_create_extra, {})
- self.assertIn('Invalid PCI alias definition', six.text_type(ex))
+ self.assertIn('Invalid PCI alias definition', str(ex))
def test_create_instance_with_user_data(self):
value = base64.encode_as_text("A random string")
@@ -6577,7 +6574,7 @@ class ServersControllerCreateTestV237(test.NoDBTestCase):
ex = self.assertRaises(
webob.exc.HTTPBadRequest, self._create_server, 'auto')
# make sure it was a flavor not found error and not something else
- self.assertIn('Flavor 2 could not be found', six.text_type(ex))
+ self.assertIn('Flavor 2 could not be found', str(ex))
@mock.patch.object(objects.Flavor, 'get_by_flavor_id',
side_effect=exception.FlavorNotFound(flavor_id='2'))
@@ -6589,7 +6586,7 @@ class ServersControllerCreateTestV237(test.NoDBTestCase):
ex = self.assertRaises(
webob.exc.HTTPBadRequest, self._create_server, 'none')
# make sure it was a flavor not found error and not something else
- self.assertIn('Flavor 2 could not be found', six.text_type(ex))
+ self.assertIn('Flavor 2 could not be found', str(ex))
@mock.patch.object(objects.Flavor, 'get_by_flavor_id',
side_effect=exception.FlavorNotFound(flavor_id='2'))
@@ -6604,7 +6601,7 @@ class ServersControllerCreateTestV237(test.NoDBTestCase):
[{'uuid': 'e3b686a8-b91d-4a61-a3fc-1b74bb619ddb'},
{'uuid': 'e0f00941-f85f-46ec-9315-96ded58c2f14'}])
# make sure it was a flavor not found error and not something else
- self.assertIn('Flavor 2 could not be found', six.text_type(ex))
+ self.assertIn('Flavor 2 could not be found', str(ex))
def test_create_server_legacy_neutron_network_id_fails(self):
"""Tests that we no longer support the legacy br-<uuid> format for
@@ -6688,7 +6685,7 @@ class ServersControllerCreateTestV257(test.NoDBTestCase):
req.headers['content-type'] = 'application/json'
ex = self.assertRaises(
exception.ValidationError, controller.create, req, body=body)
- self.assertIn('personality', six.text_type(ex))
+ self.assertIn('personality', str(ex))
@mock.patch('nova.compute.utils.check_num_instances_quota',
@@ -6745,7 +6742,7 @@ class ServersControllerCreateTestV260(test.NoDBTestCase):
ex = self.assertRaises(webob.exc.HTTPBadRequest,
self._post_server, '2.59')
self.assertIn('Multiattach volumes are only supported starting with '
- 'compute API version 2.60', six.text_type(ex))
+ 'compute API version 2.60', str(ex))
class ServersControllerCreateTestV263(ServersControllerCreateTest):
@@ -6779,7 +6776,7 @@ class ServersControllerCreateTestV263(ServersControllerCreateTest):
ex = self.assertRaises(
exception.ValidationError, self.controller.create, self.req,
body=self.body)
- self.assertIn('is too short', six.text_type(ex))
+ self.assertIn('is too short', str(ex))
def test_create_instance_with_empty_trusted_certs(self):
"""Make sure we can't create with an empty array of IDs"""
@@ -6790,7 +6787,7 @@ class ServersControllerCreateTestV263(ServersControllerCreateTest):
ex = self.assertRaises(
exception.ValidationError, self.controller.create, self.req,
body=self.body)
- self.assertIn('is too short', six.text_type(ex))
+ self.assertIn('is too short', str(ex))
def test_create_instance_with_too_many_trusted_certs(self):
"""Make sure we can't create with an array of >50 unique IDs"""
@@ -6798,7 +6795,7 @@ class ServersControllerCreateTestV263(ServersControllerCreateTest):
ex = self.assertRaises(
exception.ValidationError, self.controller.create, self.req,
body=self.body)
- self.assertIn('is too long', six.text_type(ex))
+ self.assertIn('is too long', str(ex))
def test_create_instance_with_nonunique_trusted_certs(self):
"""Make sure we can't create with a non-unique array of IDs"""
@@ -6806,7 +6803,7 @@ class ServersControllerCreateTestV263(ServersControllerCreateTest):
ex = self.assertRaises(
exception.ValidationError, self.controller.create, self.req,
body=self.body)
- self.assertIn('has non-unique elements', six.text_type(ex))
+ self.assertIn('has non-unique elements', str(ex))
def test_create_instance_with_invalid_trusted_cert_id(self):
"""Make sure we can't create with non-string certificate IDs"""
@@ -6814,7 +6811,7 @@ class ServersControllerCreateTestV263(ServersControllerCreateTest):
ex = self.assertRaises(
exception.ValidationError, self.controller.create, self.req,
body=self.body)
- self.assertIn('is not of type', six.text_type(ex))
+ self.assertIn('is not of type', str(ex))
def test_create_instance_with_invalid_trusted_certs(self):
"""Make sure we can't create with certificates in a non-array"""
@@ -6822,7 +6819,7 @@ class ServersControllerCreateTestV263(ServersControllerCreateTest):
ex = self.assertRaises(
exception.ValidationError, self.controller.create, self.req,
body=self.body)
- self.assertIn('is not of type', six.text_type(ex))
+ self.assertIn('is not of type', str(ex))
def test_create_server_with_trusted_certs_pre_2_63_fails(self):
"""Make sure we can't use trusted_certs before 2.63"""
@@ -6832,8 +6829,7 @@ class ServersControllerCreateTestV263(ServersControllerCreateTest):
ex = self.assertRaises(
exception.ValidationError, self.controller.create, self.req,
body=self.body)
- self.assertIn('Additional properties are not allowed',
- six.text_type(ex))
+ self.assertIn('Additional properties are not allowed', str(ex))
def test_create_server_with_trusted_certs_policy_failed(self):
rule_name = "os_compute_api:servers:create:trusted_certs"
@@ -6861,8 +6857,7 @@ class ServersControllerCreateTestV263(ServersControllerCreateTest):
ex = self.assertRaises(webob.exc.HTTPBadRequest,
self.controller.create, self.req,
body=self.body)
- self.assertIn('test cert validation error',
- six.text_type(ex))
+ self.assertIn('test cert validation error', str(ex))
class ServersControllerCreateTestV267(ServersControllerCreateTest):
@@ -6894,7 +6889,7 @@ class ServersControllerCreateTestV267(ServersControllerCreateTest):
ex = self.assertRaises(
exception.ValidationError, self.controller.create, self.req,
body=self.body)
- self.assertIn("'volume_type' was unexpected", six.text_type(ex))
+ self.assertIn("'volume_type' was unexpected", str(ex))
@mock.patch.object(compute_api.API, 'create',
side_effect=exception.VolumeTypeNotFound(
@@ -6906,8 +6901,7 @@ class ServersControllerCreateTestV267(ServersControllerCreateTest):
params = {'block_device_mapping_v2': self.block_device_mapping_v2}
ex = self.assertRaises(webob.exc.HTTPBadRequest,
self._test_create_extra, params)
- self.assertIn('Volume type fake-lvm-1 could not be found',
- six.text_type(ex))
+ self.assertIn('Volume type fake-lvm-1 could not be found', str(ex))
def test_create_instance_with_volume_type_empty_string(self):
"""Test passing volume_type='' which is accepted but not used."""
@@ -6933,7 +6927,7 @@ class ServersControllerCreateTestV267(ServersControllerCreateTest):
params = {'block_device_mapping_v2': self.block_device_mapping_v2}
ex = self.assertRaises(exception.ValidationError,
self._test_create_extra, params)
- self.assertIn('is too long', six.text_type(ex))
+ self.assertIn('is too long', str(ex))
class ServersControllerCreateTestV274(ServersControllerCreateTest):
@@ -6965,8 +6959,7 @@ class ServersControllerCreateTestV274(ServersControllerCreateTest):
ex = self.assertRaises(webob.exc.HTTPBadRequest,
self.controller.create,
self.req, body=self.body)
- self.assertIn('Compute host node-invalid could not be found.',
- six.text_type(ex))
+ self.assertIn('Compute host node-invalid could not be found.', str(ex))
def test_create_instance_with_non_string_host(self):
self._generate_req(host=123)
@@ -6974,8 +6967,7 @@ class ServersControllerCreateTestV274(ServersControllerCreateTest):
ex = self.assertRaises(exception.ValidationError,
self.controller.create,
self.req, body=self.body)
- self.assertIn("Invalid input for field/attribute host.",
- six.text_type(ex))
+ self.assertIn("Invalid input for field/attribute host.", str(ex))
def test_create_instance_with_invalid_hypervisor_hostname(self):
get_resp = mock.Mock()
@@ -6987,8 +6979,7 @@ class ServersControllerCreateTestV274(ServersControllerCreateTest):
ex = self.assertRaises(webob.exc.HTTPBadRequest,
self.controller.create,
self.req, body=self.body)
- self.assertIn('Compute host node-invalid could not be found.',
- six.text_type(ex))
+ self.assertIn('Compute host node-invalid could not be found.', str(ex))
def test_create_instance_with_non_string_hypervisor_hostname(self):
get_resp = mock.Mock()
@@ -7001,7 +6992,7 @@ class ServersControllerCreateTestV274(ServersControllerCreateTest):
self.controller.create,
self.req, body=self.body)
self.assertIn("Invalid input for field/attribute hypervisor_hostname.",
- six.text_type(ex))
+ str(ex))
def test_create_instance_with_invalid_host_and_hypervisor_hostname(self):
self._generate_req(host='host-invalid', node='node-invalid')
@@ -7009,8 +7000,7 @@ class ServersControllerCreateTestV274(ServersControllerCreateTest):
ex = self.assertRaises(webob.exc.HTTPBadRequest,
self.controller.create,
self.req, body=self.body)
- self.assertIn('Compute host host-invalid could not be found.',
- six.text_type(ex))
+ self.assertIn('Compute host host-invalid could not be found.', str(ex))
def test_create_instance_with_non_string_host_and_hypervisor_hostname(
self):
@@ -7019,8 +7009,7 @@ class ServersControllerCreateTestV274(ServersControllerCreateTest):
ex = self.assertRaises(exception.ValidationError,
self.controller.create,
self.req, body=self.body)
- self.assertIn("Invalid input for field/attribute",
- six.text_type(ex))
+ self.assertIn("Invalid input for field/attribute", str(ex))
def test_create_instance_pre_274(self):
self._generate_req(host='host', node='node', api_version='2.73')
@@ -7028,8 +7017,7 @@ class ServersControllerCreateTestV274(ServersControllerCreateTest):
ex = self.assertRaises(exception.ValidationError,
self.controller.create,
self.req, body=self.body)
- self.assertIn("Invalid input for field/attribute server.",
- six.text_type(ex))
+ self.assertIn("Invalid input for field/attribute server.", str(ex))
def test_create_instance_mutual(self):
self._generate_req(host='host', node='node', az='nova:host:node')
@@ -7037,7 +7025,7 @@ class ServersControllerCreateTestV274(ServersControllerCreateTest):
ex = self.assertRaises(webob.exc.HTTPBadRequest,
self.controller.create,
self.req, body=self.body)
- self.assertIn("mutually exclusive", six.text_type(ex))
+ self.assertIn("mutually exclusive", str(ex))
def test_create_instance_private_flavor(self):
# Here we use admin context, so if we do not pass it or
diff --git a/nova/tests/unit/api/openstack/compute/test_services.py b/nova/tests/unit/api/openstack/compute/test_services.py
index 170b39f208..8d77ad0d9f 100644
--- a/nova/tests/unit/api/openstack/compute/test_services.py
+++ b/nova/tests/unit/api/openstack/compute/test_services.py
@@ -20,7 +20,6 @@ from keystoneauth1 import exceptions as ks_exc
import mock
from oslo_utils import fixture as utils_fixture
from oslo_utils.fixture import uuidsentinel
-import six
import webob.exc
from nova.api.openstack.compute import services as services_v21
@@ -1191,13 +1190,13 @@ class ServicesTestV253(test.TestCase):
"""Tests that the service uuid is validated in a DELETE request."""
ex = self.assertRaises(webob.exc.HTTPBadRequest,
self.controller.delete, self.req, 1234)
- self.assertIn('Invalid uuid', six.text_type(ex))
+ self.assertIn('Invalid uuid', str(ex))
def test_update_invalid_service_uuid(self):
"""Tests that the service uuid is validated in a PUT request."""
ex = self.assertRaises(webob.exc.HTTPBadRequest,
self.controller.update, self.req, 1234, body={})
- self.assertIn('Invalid uuid', six.text_type(ex))
+ self.assertIn('Invalid uuid', str(ex))
def test_update_policy_failed(self):
"""Tests that policy is checked with microversion 2.53."""
@@ -1270,7 +1269,7 @@ class ServicesTestV253(test.TestCase):
body={'status': 'enabled',
'disabled_reason': 'invalid'})
self.assertIn("Specifying 'disabled_reason' with status 'enabled' "
- "is invalid.", six.text_type(ex))
+ "is invalid.", str(ex))
def test_update_disabled_reason_and_forced_down(self):
"""Tests disabling a service with a reason and forcing it down is
@@ -1321,7 +1320,7 @@ class ServicesTestV253(test.TestCase):
body={'forced_down': True})
self.assertEqual('Updating a nova-scheduler service is not supported. '
'Only nova-compute services can be updated.',
- six.text_type(ex))
+ str(ex))
def test_update_empty_body(self):
"""Tests that the caller gets a 400 error if they don't request any
@@ -1333,7 +1332,7 @@ class ServicesTestV253(test.TestCase):
self.req, service.uuid, body={})
self.assertEqual("No updates were requested. Fields 'status' or "
"'forced_down' should be specified.",
- six.text_type(ex))
+ str(ex))
def test_update_only_disabled_reason(self):
"""Tests that the caller gets a 400 error if they only specify
@@ -1345,7 +1344,7 @@ class ServicesTestV253(test.TestCase):
body={'disabled_reason': 'missing status'})
self.assertEqual("No updates were requested. Fields 'status' or "
"'forced_down' should be specified.",
- six.text_type(ex))
+ str(ex))
class ServicesTestV275(test.TestCase):
diff --git a/nova/tests/unit/api/openstack/compute/test_shelve.py b/nova/tests/unit/api/openstack/compute/test_shelve.py
index 5a063aa7ed..9cf87d9c42 100644
--- a/nova/tests/unit/api/openstack/compute/test_shelve.py
+++ b/nova/tests/unit/api/openstack/compute/test_shelve.py
@@ -17,7 +17,6 @@ import mock
import ddt
from oslo_serialization import jsonutils
from oslo_utils.fixture import uuidsentinel as uuids
-import six
import webob
from nova.api.openstack import api_version_request
@@ -151,8 +150,7 @@ class UnshelveServerControllerTestV277(test.NoDBTestCase):
self.controller._unshelve,
self.req, fakes.FAKE_UUID,
body=body)
- self.assertIn("\'availability_zone\' is a required property",
- six.text_type(exc))
+ self.assertIn("\'availability_zone\' is a required property", str(exc))
def test_invalid_az_name_with_int(self):
body = {
@@ -187,5 +185,4 @@ class UnshelveServerControllerTestV277(test.NoDBTestCase):
exception.ValidationError,
self.controller._unshelve, self.req,
fakes.FAKE_UUID, body=body)
- self.assertIn("Additional properties are not allowed",
- six.text_type(exc))
+ self.assertIn("Additional properties are not allowed", str(exc))
diff --git a/nova/tests/unit/api/openstack/compute/test_suspend_server.py b/nova/tests/unit/api/openstack/compute/test_suspend_server.py
index 84fa0e9512..7d6857770e 100644
--- a/nova/tests/unit/api/openstack/compute/test_suspend_server.py
+++ b/nova/tests/unit/api/openstack/compute/test_suspend_server.py
@@ -13,7 +13,6 @@
# under the License.
import mock
-import six
import webob
from nova.api.openstack.compute import suspend_server as \
@@ -48,7 +47,7 @@ class SuspendServerTestsV21(admin_only_action_common.CommonTests):
self.controller._suspend,
self.req, fakes.FAKE_UUID, body={})
self.assertIn("Operation 'suspend' not supported for SEV-enabled "
- "instance (%s)" % instance.uuid, six.text_type(ex))
+ "instance (%s)" % instance.uuid, str(ex))
def test_suspend_resume_with_non_existed_instance(self):
self._test_actions_with_non_existed_instance(['_suspend', '_resume'])
diff --git a/nova/tests/unit/api/openstack/compute/test_volumes.py b/nova/tests/unit/api/openstack/compute/test_volumes.py
index 75f90bee3b..0e2fff58b4 100644
--- a/nova/tests/unit/api/openstack/compute/test_volumes.py
+++ b/nova/tests/unit/api/openstack/compute/test_volumes.py
@@ -22,7 +22,6 @@ import mock
from oslo_serialization import jsonutils
from oslo_utils import encodeutils
from oslo_utils.fixture import uuidsentinel as uuids
-import six
import webob
from webob import exc
@@ -949,7 +948,7 @@ class VolumeAttachTestsV260(test.NoDBTestCase):
create_kwargs = attach.call_args[1]
self.assertFalse(create_kwargs['supports_multiattach'])
self.assertIn('Multiattach volumes are only supported starting with '
- 'compute API version 2.60', six.text_type(ex))
+ 'compute API version 2.60', str(ex))
def test_attach_with_multiattach_fails_not_supported_by_driver(self):
"""Tests the case that the user tries to attach with a
@@ -966,7 +965,7 @@ class VolumeAttachTestsV260(test.NoDBTestCase):
create_kwargs = attach.call_args[1]
self.assertTrue(create_kwargs['supports_multiattach'])
self.assertIn("has 'multiattach' set, which is not supported for "
- "this instance", six.text_type(ex))
+ "this instance", str(ex))
def test_attach_with_multiattach_fails_for_shelved_offloaded_server(self):
"""Tests the case that the user tries to attach with a
@@ -981,7 +980,7 @@ class VolumeAttachTestsV260(test.NoDBTestCase):
create_kwargs = attach.call_args[1]
self.assertTrue(create_kwargs['supports_multiattach'])
self.assertIn('Attaching multiattach volumes is not supported for '
- 'shelved-offloaded instances.', six.text_type(ex))
+ 'shelved-offloaded instances.', str(ex))
class VolumeAttachTestsV2_75(VolumeAttachTestsV21):
@@ -1048,8 +1047,7 @@ class VolumeAttachTestsV279(VolumeAttachTestsV2_75):
ex = self.assertRaises(exception.ValidationError,
self.controller.create,
req, FAKE_UUID, body=body)
- self.assertIn("Additional properties are not allowed",
- six.text_type(ex))
+ self.assertIn("Additional properties are not allowed", str(ex))
@mock.patch('nova.compute.api.API.attach_volume', return_value=None)
def test_attach_volume_pre_v279(self, mock_attach_volume):
@@ -1089,7 +1087,7 @@ class VolumeAttachTestsV279(VolumeAttachTestsV2_75):
self.controller.create,
req, FAKE_UUID, body=body)
self.assertIn("Invalid input for field/attribute "
- "delete_on_termination.", six.text_type(ex))
+ "delete_on_termination.", str(ex))
def test_create_volume_attach_invalid_delete_on_termination_value(self):
""""Test the case that the user tries to set the delete_on_termination
@@ -1107,7 +1105,7 @@ class VolumeAttachTestsV279(VolumeAttachTestsV2_75):
self.controller.create,
req, FAKE_UUID, body=body)
self.assertIn("Invalid input for field/attribute "
- "delete_on_termination.", six.text_type(ex))
+ "delete_on_termination.", str(ex))
@mock.patch('nova.compute.api.API.attach_volume', return_value=None)
def test_attach_volume_v279(self, mock_attach_volume):
@@ -1397,8 +1395,7 @@ class UpdateVolumeAttachTests(VolumeAttachTestsV279):
self.attachments.update,
req, FAKE_UUID,
FAKE_UUID_A, body=body)
- self.assertIn('Additional properties are not allowed',
- six.text_type(ex))
+ self.assertIn('Additional properties are not allowed', str(ex))
@mock.patch.object(objects.BlockDeviceMapping,
'get_by_volume_and_instance')
@@ -1440,8 +1437,7 @@ class UpdateVolumeAttachTests(VolumeAttachTestsV279):
self.attachments.update,
req, FAKE_UUID,
FAKE_UUID_A, body=body)
- self.assertIn('Additional properties are not allowed',
- six.text_type(ex))
+ self.assertIn('Additional properties are not allowed', str(ex))
@mock.patch.object(objects.BlockDeviceMapping,
'get_by_volume_and_instance')
@@ -1479,8 +1475,7 @@ class UpdateVolumeAttachTests(VolumeAttachTestsV279):
self.attachments.update,
req, FAKE_UUID,
FAKE_UUID_A, body=body)
- self.assertIn('Additional properties are not allowed',
- six.text_type(ex))
+ self.assertIn('Additional properties are not allowed', str(ex))
@mock.patch.object(objects.BlockDeviceMapping,
'get_by_volume_and_instance')
@@ -1518,8 +1513,7 @@ class UpdateVolumeAttachTests(VolumeAttachTestsV279):
self.attachments.update,
req, FAKE_UUID,
FAKE_UUID_A, body=body)
- self.assertIn('Additional properties are not allowed',
- six.text_type(ex))
+ self.assertIn('Additional properties are not allowed', str(ex))
def test_update_volume_with_delete_flag_old_microversion(self):
body = {'volumeAttachment': {
@@ -1531,8 +1525,7 @@ class UpdateVolumeAttachTests(VolumeAttachTestsV279):
self.attachments.update,
req, FAKE_UUID,
FAKE_UUID_A, body=body)
- self.assertIn('Additional properties are not allowed',
- six.text_type(ex))
+ self.assertIn('Additional properties are not allowed', str(ex))
class SwapVolumeMultiattachTestCase(test.NoDBTestCase):
@@ -1603,7 +1596,7 @@ class SwapVolumeMultiattachTestCase(test.NoDBTestCase):
webob.exc.HTTPBadRequest, controller.update, req,
uuids.server1, uuids.old_vol_id, body=body)
self.assertIn('Swapping multi-attach volumes with more than one ',
- six.text_type(ex))
+ str(ex))
mock_attachment_get.assert_has_calls([
mock.call(ctxt, uuids.attachment_id1),
mock.call(ctxt, uuids.attachment_id2)], any_order=True)
@@ -1866,7 +1859,7 @@ class AssistedSnapshotDeleteTestCaseV21(test.NoDBTestCase):
self.controller.delete, req, '5')
# This is the result of a KeyError but the only thing in the message
# is the missing key.
- self.assertIn('volume_id', six.text_type(ex))
+ self.assertIn('volume_id', str(ex))
class AssistedSnapshotDeleteTestCaseV275(AssistedSnapshotDeleteTestCaseV21):
diff --git a/nova/tests/unit/api/openstack/test_common.py b/nova/tests/unit/api/openstack/test_common.py
index 8c85b79201..4666413e27 100644
--- a/nova/tests/unit/api/openstack/test_common.py
+++ b/nova/tests/unit/api/openstack/test_common.py
@@ -18,7 +18,6 @@ Test suites for 'common' code used throughout the OpenStack HTTP API.
"""
import mock
-import six
from testtools import matchers
import webob
import webob.exc
@@ -367,7 +366,7 @@ class MiscFunctionsTest(test.TestCase):
common.raise_http_conflict_for_instance_invalid_state(exc,
'meow', 'fake_server_id')
except webob.exc.HTTPConflict as e:
- self.assertEqual(six.text_type(e),
+ self.assertEqual(str(e),
"Cannot 'meow' instance fake_server_id while it is in "
"fake_attr fake_state")
else: