From 791648860f797ee20b831dfdb9d16914d4cde1f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Beraud?= Date: Wed, 20 Nov 2019 19:37:26 +0100 Subject: [PATCH] Remove six and python 2.7 full support Six is in use to help us to keep support for python 2.7. Since the ussuri cycle we decide to remove the python 2.7 support so we can go ahead and also remove six usage from the python code. Review process and help ----------------------- Removing six introduce a lot of changes and an huge amount of modified files To simplify reviews we decided to split changes into several patches to avoid painful reviews and avoid mistakes. To review this patch you can use the six documentation [1] to obtain help and understand choices. Additional informations ----------------------- Changes related to 'six.b(data)' [2] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ six.b [2] encode the given datas in latin-1 in python3 so I did the same things in this patch. Latin-1 is equal to iso-8859-1 [3]. This encoding is the default encoding [4] of certain descriptive HTTP headers. I suggest to keep latin-1 for the moment and to move to another encoding in a follow-up patch if needed to move to most powerful encoding (utf8). HTML4 support utf8 charset and utf8 is the default charset for HTML5 [5]. Note that this commit message is autogenerated and not necesserly contains changes related to 'six.b' [1] https://six.readthedocs.io/ [2] https://six.readthedocs.io/#six.b [3] https://docs.python.org/3/library/codecs.html#standard-encodings [4] https://www.w3schools.com/charsets/ref_html_8859.asp [5] https://www.w3schools.com/html/html_charset.asp Patch 15 of a serie of 28 patches Change-Id: I53775221843caa0e64f711cf35352fba8420a66d --- .../tests/api/openstack_v1/test_build_info.py | 3 +- heat/tests/api/openstack_v1/test_events.py | 7 ++- heat/tests/api/openstack_v1/test_resources.py | 23 +++++---- heat/tests/api/openstack_v1/test_stacks.py | 49 +++++++++---------- .../api/openstack_v1/test_views_common.py | 2 +- heat/tests/api/openstack_v1/tools.py | 3 +- heat/tests/api/test_wsgi.py | 7 ++- .../autoscaling/test_heat_scaling_group.py | 15 +++--- .../autoscaling/test_heat_scaling_policy.py | 5 +- heat/tests/autoscaling/test_launch_config.py | 13 +++-- 10 files changed, 59 insertions(+), 68 deletions(-) diff --git a/heat/tests/api/openstack_v1/test_build_info.py b/heat/tests/api/openstack_v1/test_build_info.py index c7fb45043e..c958068d63 100644 --- a/heat/tests/api/openstack_v1/test_build_info.py +++ b/heat/tests/api/openstack_v1/test_build_info.py @@ -12,7 +12,6 @@ # under the License. import mock -import six import heat.api.middleware.fault as fault import heat.api.openstack.v1.build_info as build_info @@ -72,4 +71,4 @@ class BuildInfoControllerTest(tools.ControllerTest, common.HeatTestCase): self.controller.build_info, req, tenant_id=self.tenant) self.assertEqual(403, resp.status_int) - self.assertIn('403 Forbidden', six.text_type(resp)) + self.assertIn('403 Forbidden', str(resp)) diff --git a/heat/tests/api/openstack_v1/test_events.py b/heat/tests/api/openstack_v1/test_events.py index c3a0b54abc..217ae51bb4 100644 --- a/heat/tests/api/openstack_v1/test_events.py +++ b/heat/tests/api/openstack_v1/test_events.py @@ -12,7 +12,6 @@ # under the License. import mock -import six import webob.exc import heat.api.middleware.fault as fault @@ -341,7 +340,7 @@ class EventControllerTest(tools.ControllerTest, common.HeatTestCase): stack_id=stack_identity.stack_id) self.assertEqual(403, resp.status_int) - self.assertIn('403 Forbidden', six.text_type(resp)) + self.assertIn('403 Forbidden', str(resp)) def test_index_resource_nonexist(self, mock_enforce): self._mock_enforce_setup(mock_enforce, 'index', True) @@ -424,7 +423,7 @@ class EventControllerTest(tools.ControllerTest, common.HeatTestCase): stack_name=sid.stack_name, stack_id=sid.stack_id) self.assertEqual("Only integer is acceptable by 'limit'.", - six.text_type(ex)) + str(ex)) self.assertFalse(mock_call.called) @mock.patch.object(rpc_client.EngineClient, 'call') @@ -631,7 +630,7 @@ class EventControllerTest(tools.ControllerTest, common.HeatTestCase): event_id=event_id) self.assertEqual(403, resp.status_int) - self.assertIn('403 Forbidden', six.text_type(resp)) + self.assertIn('403 Forbidden', str(resp)) @mock.patch.object(rpc_client.EngineClient, 'call') def test_show_multiple_resource_names(self, mock_call, mock_enforce): diff --git a/heat/tests/api/openstack_v1/test_resources.py b/heat/tests/api/openstack_v1/test_resources.py index c8e3945783..5af626c3fb 100644 --- a/heat/tests/api/openstack_v1/test_resources.py +++ b/heat/tests/api/openstack_v1/test_resources.py @@ -12,7 +12,6 @@ # under the License. import mock -import six import webob.exc import heat.api.middleware.fault as fault @@ -147,8 +146,8 @@ class ResourceControllerTest(tools.ControllerTest, common.HeatTestCase): stack_id=stack_identity.stack_id) self.assertIn("Invalid filter parameters %s" % - [six.text_type('invalid_key')], - six.text_type(ex)) + [str('invalid_key')], + str(ex)) self.assertFalse(mock_call.called) def test_index_nested_depth(self, mock_enforce): @@ -192,7 +191,7 @@ class ResourceControllerTest(tools.ControllerTest, common.HeatTestCase): stack_id=stack_identity.stack_id) self.assertEqual("Only integer is acceptable by 'nested_depth'.", - six.text_type(ex)) + str(ex)) self.assertFalse(mock_call.called) def test_index_denied_policy(self, mock_enforce): @@ -213,7 +212,7 @@ class ResourceControllerTest(tools.ControllerTest, common.HeatTestCase): stack_id=stack_identity.stack_id) self.assertEqual(403, resp.status_int) - self.assertIn('403 Forbidden', six.text_type(resp)) + self.assertIn('403 Forbidden', str(resp)) def test_index_detail(self, mock_enforce): self._mock_enforce_setup(mock_enforce, 'index', True) @@ -562,7 +561,7 @@ class ResourceControllerTest(tools.ControllerTest, common.HeatTestCase): resource_name=res_name) self.assertEqual(403, resp.status_int) - self.assertIn('403 Forbidden', six.text_type(resp)) + self.assertIn('403 Forbidden', str(resp)) def test_metadata_show(self, mock_enforce): self._mock_enforce_setup(mock_enforce, 'metadata', True) @@ -693,7 +692,7 @@ class ResourceControllerTest(tools.ControllerTest, common.HeatTestCase): resource_name=res_name) self.assertEqual(403, resp.status_int) - self.assertIn('403 Forbidden', six.text_type(resp)) + self.assertIn('403 Forbidden', str(resp)) def test_signal(self, mock_enforce): self._mock_enforce_setup(mock_enforce, 'signal', True) @@ -808,9 +807,9 @@ class ResourceControllerTest(tools.ControllerTest, common.HeatTestCase): resource_name=res_name, body=body) - self.assertIn(expected, six.text_type(actual)) - self.assertIn('invalid_key1', six.text_type(actual)) - self.assertIn('invalid_key2', six.text_type(actual)) + self.assertIn(expected, str(actual)) + self.assertIn('invalid_key1', str(actual)) + self.assertIn('invalid_key2', str(actual)) mock_call.assert_not_called() def test_mark_unhealthy_with_invalid_value(self, mock_enforce): @@ -837,7 +836,7 @@ class ResourceControllerTest(tools.ControllerTest, common.HeatTestCase): resource_name=res_name, body=body) - self.assertIn(expected, six.text_type(actual)) + self.assertIn(expected, str(actual)) mock_call.assert_not_called() def test_mark_unhealthy_without_mark_unhealthy_key(self, mock_enforce): @@ -863,5 +862,5 @@ class ResourceControllerTest(tools.ControllerTest, common.HeatTestCase): resource_name=res_name, body=body) - self.assertIn(expected, six.text_type(actual)) + self.assertIn(expected, str(actual)) mock_call.assert_not_called() diff --git a/heat/tests/api/openstack_v1/test_stacks.py b/heat/tests/api/openstack_v1/test_stacks.py index b0c51799af..f27253a4e2 100644 --- a/heat/tests/api/openstack_v1/test_stacks.py +++ b/heat/tests/api/openstack_v1/test_stacks.py @@ -15,7 +15,6 @@ import json import mock from oslo_config import cfg -import six import webob.exc import heat.api.middleware.fault as fault @@ -61,7 +60,7 @@ parameters: template_format.parse(bad_temp) parse_ex = self.assertRaises(webob.exc.HTTPBadRequest, generate_error) - self.assertIn('foo', six.text_type(parse_ex)) + self.assertIn('foo', str(parse_ex)) def test_stack_name(self): body = {'stack_name': 'wibble'} @@ -148,7 +147,7 @@ blarg: wibble 'bytes) exceeds maximum allowed size (%(limit)s bytes).') % { 'actual_len': len(str(template)), 'limit': cfg.CONF.max_template_size} - self.assertEqual(msg, six.text_type(error)) + self.assertEqual(msg, str(error)) def test_parameters(self): params = {'foo': 'bar', 'blarg': 'wibble'} @@ -348,7 +347,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase): self.controller.index, req, tenant_id=self.tenant) self.assertEqual("Only integer is acceptable by 'limit'.", - six.text_type(ex)) + str(ex)) self.assertFalse(mock_call.called) @mock.patch.object(rpc_client.EngineClient, 'call') @@ -444,7 +443,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase): req, tenant_id=self.tenant) excepted = ('Unrecognized value "invalid_value" for "with_count", ' 'acceptable values are: true, false') - self.assertIn(excepted, six.text_type(exc)) + self.assertIn(excepted, str(exc)) @mock.patch.object(rpc_client.EngineClient, 'count_stacks') def test_index_doesnt_break_with_old_engine(self, mock_count_stacks, @@ -701,7 +700,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase): req, tenant_id=self.tenant) self.assertEqual(403, resp.status_int) - self.assertIn('403 Forbidden', six.text_type(resp)) + self.assertIn('403 Forbidden', str(resp)) @mock.patch.object(rpc_client.EngineClient, 'call') def test_index_rmt_interr(self, mock_call, mock_enforce): @@ -900,7 +899,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase): tenant_id=self.tenant, body=body) self.assertEqual("Only integer is acceptable by 'timeout_mins'.", - six.text_type(ex)) + str(ex)) mock_call.assert_not_called() def test_adopt_error(self, mock_enforce): @@ -1106,7 +1105,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase): tenant_id=self.tenant, body=body) self.assertEqual("Only integer is acceptable by 'timeout_mins'.", - six.text_type(ex)) + str(ex)) mock_call.assert_not_called() def test_create_err_denied_policy(self, mock_enforce): @@ -1127,7 +1126,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase): body=body) self.assertEqual(403, resp.status_int) - self.assertIn('403 Forbidden', six.text_type(resp)) + self.assertIn('403 Forbidden', str(resp)) def test_create_err_engine(self, mock_enforce): self._mock_enforce_setup(mock_enforce, 'create', True) @@ -1365,7 +1364,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase): self.assertEqual('ImmutableParameterModified', resp.json['error']['type']) self.assertIn("The following parameters are immutable", - six.text_type(resp.json['error']['message'])) + str(resp.json['error']['message'])) mock_call.assert_called_once_with( req.context, @@ -1452,7 +1451,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase): stack_name=stack_name) self.assertEqual(403, resp.status_int) - self.assertIn('403 Forbidden', six.text_type(resp)) + self.assertIn('403 Forbidden', str(resp)) def test_lookup_resource(self, mock_enforce): self._mock_enforce_setup(mock_enforce, 'lookup', True) @@ -1514,7 +1513,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase): path='resources') self.assertEqual(403, resp.status_int) - self.assertIn('403 Forbidden', six.text_type(resp)) + self.assertIn('403 Forbidden', str(resp)) def test_show(self, mock_enforce): self._mock_enforce_setup(mock_enforce, 'show', True) @@ -1688,7 +1687,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase): stack_id=identity.stack_id) self.assertEqual(403, resp.status_int) - self.assertIn('403 Forbidden', six.text_type(resp)) + self.assertIn('403 Forbidden', str(resp)) def test_show_err_denied_policy(self, mock_enforce): self._mock_enforce_setup(mock_enforce, 'show', False) @@ -1703,7 +1702,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase): stack_id=identity.stack_id) self.assertEqual(403, resp.status_int) - self.assertIn('403 Forbidden', six.text_type(resp)) + self.assertIn('403 Forbidden', str(resp)) def test_get_template(self, mock_enforce): self._mock_enforce_setup(mock_enforce, 'template', True) @@ -1780,7 +1779,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase): stack_id=identity.stack_id) self.assertEqual(403, resp.status_int) - self.assertIn('403 Forbidden', six.text_type(resp)) + self.assertIn('403 Forbidden', str(resp)) def test_get_template_err_notfound(self, mock_enforce): self._mock_enforce_setup(mock_enforce, 'template', True) @@ -1954,7 +1953,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase): stack_id=identity.stack_id, body=body) self.assertEqual("Only integer is acceptable by 'timeout_mins'.", - six.text_type(ex)) + str(ex)) self.assertFalse(mock_call.called) def test_update_err_denied_policy(self, mock_enforce): @@ -1978,7 +1977,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase): body=body) self.assertEqual(403, resp.status_int) - self.assertIn('403 Forbidden', six.text_type(resp)) + self.assertIn('403 Forbidden', str(resp)) def test_update_with_existing_template(self, mock_enforce): self._mock_enforce_setup(mock_enforce, 'update_patch', True) @@ -2167,7 +2166,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase): stack_id=identity.stack_id, body=body) self.assertEqual("Only integer is acceptable by 'timeout_mins'.", - six.text_type(ex)) + str(ex)) self.assertFalse(mock_call.called) def test_update_with_existing_and_default_parameters( @@ -2295,7 +2294,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase): stack_id=identity.stack_id) self.assertEqual(403, resp.status_int) - self.assertIn('403 Forbidden', six.text_type(resp)) + self.assertIn('403 Forbidden', str(resp)) def test_export(self, mock_enforce): self._mock_enforce_setup(mock_enforce, 'export', True) @@ -2354,7 +2353,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase): stack_id=identity.stack_id) self.assertEqual(403, resp.status_int) - self.assertIn('403 Forbidden', six.text_type(resp)) + self.assertIn('403 Forbidden', str(resp)) def test_delete_bad_name(self, mock_enforce): self._mock_enforce_setup(mock_enforce, 'delete', True) @@ -2468,7 +2467,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase): req, tenant_id=self.tenant, body=body) self.assertEqual(403, resp.status_int) - self.assertIn('403 Forbidden', six.text_type(resp)) + self.assertIn('403 Forbidden', str(resp)) def test_list_resource_types(self, mock_enforce): self._mock_enforce_setup(mock_enforce, 'list_resource_types', True) @@ -2534,7 +2533,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase): req, tenant_id=self.tenant) self.assertEqual(403, resp.status_int) - self.assertIn('403 Forbidden', six.text_type(resp)) + self.assertIn('403 Forbidden', str(resp)) def test_list_outputs(self, mock_enforce): self._mock_enforce_setup(mock_enforce, 'list_outputs', True) @@ -2732,7 +2731,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase): req, tenant_id=self.tenant, type_name=type_name) self.assertEqual(403, resp.status_int) - self.assertIn('403 Forbidden', six.text_type(resp)) + self.assertIn('403 Forbidden', str(resp)) def test_generate_template(self, mock_enforce): self._mock_enforce_setup(mock_enforce, 'generate_template', True) @@ -2766,7 +2765,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase): type_name='TEST_TYPE') self.assertIn('Template type is not supported: Invalid template ' 'type "invalid", valid types are: cfn, hot.', - six.text_type(ex)) + str(ex)) self.assertFalse(mock_call.called) def test_generate_template_not_found(self, mock_enforce): @@ -2800,7 +2799,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase): req, tenant_id=self.tenant, type_name='blah') self.assertEqual(403, resp.status_int) - self.assertIn('403 Forbidden', six.text_type(resp)) + self.assertIn('403 Forbidden', str(resp)) class StackSerializerTest(common.HeatTestCase): diff --git a/heat/tests/api/openstack_v1/test_views_common.py b/heat/tests/api/openstack_v1/test_views_common.py index 9b69efb8fb..1f3fb238cb 100644 --- a/heat/tests/api/openstack_v1/test_views_common.py +++ b/heat/tests/api/openstack_v1/test_views_common.py @@ -12,7 +12,7 @@ # under the License. import mock -from six.moves.urllib import parse as urlparse +from urllib import parse as urlparse from heat.api.openstack.v1.views import views_common from heat.tests import common diff --git a/heat/tests/api/openstack_v1/tools.py b/heat/tests/api/openstack_v1/tools.py index 3a27b8697e..7ed27ee33c 100644 --- a/heat/tests/api/openstack_v1/tools.py +++ b/heat/tests/api/openstack_v1/tools.py @@ -15,7 +15,6 @@ import mock from oslo_config import cfg from oslo_log import log from oslo_messaging._drivers import common as rpc_common -import six import webob.exc from heat.common import wsgi @@ -94,7 +93,7 @@ class ControllerTest(object): req = wsgi.Request(environ) req.context = utils.dummy_context('api_test_user', self.tenant) self.context = req.context - req.body = six.b(data) + req.body = data.encode('latin-1') return req def _post(self, path, data, content_type='application/json'): diff --git a/heat/tests/api/test_wsgi.py b/heat/tests/api/test_wsgi.py index c91336bbef..9d273d536b 100644 --- a/heat/tests/api/test_wsgi.py +++ b/heat/tests/api/test_wsgi.py @@ -18,7 +18,6 @@ import fixtures import json import mock -import six import socket import webob @@ -214,7 +213,7 @@ class ResourceTest(common.HeatTestCase): None) e = self.assertRaises(exception.HTTPExceptionDisguise, resource, request) - self.assertEqual(message_es, six.text_type(e.exc)) + self.assertEqual(message_es, str(e.exc)) class ResourceExceptionHandlingTest(common.HeatTestCase): @@ -250,7 +249,7 @@ class ResourceExceptionHandlingTest(common.HeatTestCase): None) e = self.assertRaises(self.exception_catch, resource, request) e = e.exc if hasattr(e, 'exc') else e - self.assertNotIn(six.text_type(e), self.LOG.output) + self.assertNotIn(str(e), self.LOG.output) class JSONRequestDeserializerTest(common.HeatTestCase): @@ -387,7 +386,7 @@ class JSONRequestDeserializerTest(common.HeatTestCase): msg = ('Request limit exceeded: JSON body size ' '(%s bytes) exceeds maximum allowed size (%s bytes).' % ( len(body), cfg.CONF.max_json_body_size)) - self.assertEqual(msg, six.text_type(error)) + self.assertEqual(msg, str(error)) class GetSocketTestCase(common.HeatTestCase): diff --git a/heat/tests/autoscaling/test_heat_scaling_group.py b/heat/tests/autoscaling/test_heat_scaling_group.py index 8a107ec254..031460ebf7 100644 --- a/heat/tests/autoscaling/test_heat_scaling_group.py +++ b/heat/tests/autoscaling/test_heat_scaling_group.py @@ -15,7 +15,6 @@ import json import mock from oslo_utils import timeutils -import six from heat.common import exception from heat.common import grouputils @@ -499,7 +498,7 @@ class HeatScalingGroupAttrFallbackTest(common.HeatTestCase): mock_members = self.patchobject(grouputils, 'get_members') members = [] output = [] - for ip_ex in six.moves.range(1, 4): + for ip_ex in range(1, 4): inst = mock.Mock() inst.FnGetAtt.return_value = '2.1.3.%d' % ip_ex output.append('2.1.3.%d' % ip_ex) @@ -543,7 +542,7 @@ class HeatScalingGroupAttrFallbackTest(common.HeatTestCase): mock_members = self.patchobject(grouputils, 'get_members') members = [] output = {} - for ip_ex in six.moves.range(1, 4): + for ip_ex in range(1, 4): inst = mock.Mock() inst.name = str(ip_ex) inst.FnGetAtt.return_value = '2.1.3.%d' % ip_ex @@ -559,7 +558,7 @@ class HeatScalingGroupAttrFallbackTest(common.HeatTestCase): self.group.nested = mock.Mock() members = [] output = [] - for ip_ex in six.moves.range(0, 2): + for ip_ex in range(0, 2): inst = mock.Mock() inst.name = 'ab'[ip_ex] inst.FnGetAtt.return_value = '2.1.3.%d' % ip_ex @@ -644,7 +643,7 @@ class RollingUpdatePolicyTest(common.HeatTestCase): stack = utils.parse_stack(tmpl) error = self.assertRaises( exception.StackValidationFailed, stack.validate) - self.assertIn("foo", six.text_type(error)) + self.assertIn("foo", str(error)) def test_parse_with_bad_pausetime_in_update_policy(self): tmpl = template_format.parse(asg_tmpl_with_default_updt_policy()) @@ -654,7 +653,7 @@ class RollingUpdatePolicyTest(common.HeatTestCase): error = self.assertRaises( exception.StackValidationFailed, stack.validate) self.assertIn("could not convert string to float", - six.text_type(error)) + str(error)) class RollingUpdatePolicyDiffTest(common.HeatTestCase): @@ -736,7 +735,7 @@ class IncorrectUpdatePolicyTest(common.HeatTestCase): exc = self.assertRaises(exception.StackValidationFailed, stack.validate) self.assertIn('Unknown Property AutoScalingRollingUpdate', - six.text_type(exc)) + str(exc)) def test_with_update_policy_inst_group(self): t = template_format.parse(inline_templates.as_heat_template) @@ -750,7 +749,7 @@ class IncorrectUpdatePolicyTest(common.HeatTestCase): stack = utils.parse_stack(tmpl) exc = self.assertRaises(exception.StackValidationFailed, stack.validate) - self.assertIn('Unknown Property RollingUpdate', six.text_type(exc)) + self.assertIn('Unknown Property RollingUpdate', str(exc)) class TestCooldownMixin(common.HeatTestCase): diff --git a/heat/tests/autoscaling/test_heat_scaling_policy.py b/heat/tests/autoscaling/test_heat_scaling_policy.py index 1ff7339264..a3e89b67c6 100644 --- a/heat/tests/autoscaling/test_heat_scaling_policy.py +++ b/heat/tests/autoscaling/test_heat_scaling_policy.py @@ -12,7 +12,6 @@ # under the License. import mock -import six from heat.common import exception from heat.common import template_format @@ -61,7 +60,7 @@ class TestAutoScalingPolicy(common.HeatTestCase): stack.validate) self.assertIn('min_adjustment_step property should only ' 'be specified for adjustment_type with ' - 'value percent_change_in_capacity.', six.text_type(ex)) + 'value percent_change_in_capacity.', str(ex)) def test_scaling_policy_bad_group(self): t = template_format.parse(inline_templates.as_heat_template_bad_group) @@ -70,7 +69,7 @@ class TestAutoScalingPolicy(common.HeatTestCase): ex = self.assertRaises(exception.ResourceFailure, up_policy.signal) self.assertIn('Alarm my-policy could ' - 'not find scaling group', six.text_type(ex)) + 'not find scaling group', str(ex)) def test_scaling_policy_adjust_no_action(self): t = template_format.parse(as_template) diff --git a/heat/tests/autoscaling/test_launch_config.py b/heat/tests/autoscaling/test_launch_config.py index 7509564d16..d4413e8081 100644 --- a/heat/tests/autoscaling/test_launch_config.py +++ b/heat/tests/autoscaling/test_launch_config.py @@ -12,7 +12,6 @@ # under the License. import mock -import six from heat.common import exception from heat.common import short_id @@ -111,7 +110,7 @@ class LaunchConfigurationTest(common.HeatTestCase): rsrc.validate) ex_msg = ('If without InstanceId, ' 'ImageId and InstanceType are required.') - self.assertIn(ex_msg, six.text_type(e)) + self.assertIn(ex_msg, str(e)) def test_lc_validate_without_InstanceId_and_InstanceType(self): t = template_format.parse(inline_templates.as_template) @@ -126,7 +125,7 @@ class LaunchConfigurationTest(common.HeatTestCase): rsrc.validate) ex_msg = ('If without InstanceId, ' 'ImageId and InstanceType are required.') - self.assertIn(ex_msg, six.text_type(e)) + self.assertIn(ex_msg, str(e)) def test_launch_config_create_with_instanceid_not_found(self): t = template_format.parse(inline_templates.as_template) @@ -148,7 +147,7 @@ class LaunchConfigurationTest(common.HeatTestCase): exc = self.assertRaises(exception.StackValidationFailed, rsrc.validate) - self.assertIn(msg, six.text_type(exc)) + self.assertIn(msg, str(exc)) def test_validate_BlockDeviceMappings_without_Ebs_property(self): t = template_format.parse(inline_templates.as_template) @@ -164,7 +163,7 @@ class LaunchConfigurationTest(common.HeatTestCase): self.validate_launch_config, stack) self.assertIn("Ebs is missing, this is required", - six.text_type(e)) + str(e)) def test_validate_BlockDeviceMappings_without_SnapshotId_property(self): t = template_format.parse(inline_templates.as_template) @@ -181,7 +180,7 @@ class LaunchConfigurationTest(common.HeatTestCase): self.validate_launch_config, stack) self.assertIn("SnapshotId is missing, this is required", - six.text_type(e)) + str(e)) def test_validate_BlockDeviceMappings_without_DeviceName_property(self): t = template_format.parse(inline_templates.as_template) @@ -201,4 +200,4 @@ class LaunchConfigurationTest(common.HeatTestCase): 'Property error: ' 'Resources.LaunchConfig.Properties.BlockDeviceMappings[0]: ' 'Property DeviceName not assigned') - self.assertIn(excepted_error, six.text_type(e)) + self.assertIn(excepted_error, str(e))