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 27 of a serie of 28 patches

Change-Id: I85b44a770b0e98885fb10c2874d9c153cc76959a
This commit is contained in:
Hervé Beraud 2019-11-20 19:37:27 +01:00
parent d7d3dcbb50
commit 062ce29a3b
10 changed files with 97 additions and 107 deletions

View File

@ -11,7 +11,6 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import six
from heat.common import exception from heat.common import exception
from heat.common import template_format from heat.common import template_format
@ -87,7 +86,7 @@ class ResourceDefinitionTest(common.HeatTestCase):
rd = self.make_me_one_with_everything() rd = self.make_me_one_with_everything()
metadata = rd.metadata() metadata = rd.metadata()
self.assertEqual({'Baz': 'quux'}, metadata) self.assertEqual({'Baz': 'quux'}, metadata)
self.assertIsInstance(metadata['Baz'], six.string_types) self.assertIsInstance(metadata['Baz'], str)
def test_dependencies_default(self): def test_dependencies_default(self):
rd = rsrc_defn.ResourceDefinition('rsrc', 'SomeType') rd = rsrc_defn.ResourceDefinition('rsrc', 'SomeType')

View File

@ -15,8 +15,7 @@ import datetime
from keystoneauth1 import exceptions as kc_exceptions from keystoneauth1 import exceptions as kc_exceptions
import mock import mock
import six from urllib import parse as urlparse
from six.moves.urllib import parse as urlparse
from heat.common import exception from heat.common import exception
from heat.common import template_format from heat.common import template_format
@ -624,7 +623,7 @@ class SignalTest(common.HeatTestCase):
msg = 'Signal resource during %s is not supported.' % action msg = 'Signal resource during %s is not supported.' % action
exc = self.assertRaises(exception.NotSupported, rsrc.signal, exc = self.assertRaises(exception.NotSupported, rsrc.signal,
details=err_metadata) details=err_metadata)
self.assertEqual(msg, six.text_type(exc)) self.assertEqual(msg, str(exc))
def test_signal_in_delete_state(self): def test_signal_in_delete_state(self):
# assert that we get the correct exception when calling a # assert that we get the correct exception when calling a

View File

@ -22,7 +22,6 @@ import eventlet
import fixtures import fixtures
import mock import mock
from oslo_config import cfg from oslo_config import cfg
import six
from heat.common import context from heat.common import context
from heat.common import exception from heat.common import exception
@ -938,7 +937,7 @@ class StackTest(common.HeatTestCase):
def _mock_check(res): def _mock_check(res):
res.handle_check = mock.Mock() res.handle_check = mock.Mock()
[_mock_check(res) for res in six.itervalues(self.stack.resources)] [_mock_check(res) for res in self.stack.resources.values()]
return self.stack return self.stack
def test_check_supported(self): def test_check_supported(self):
@ -950,7 +949,7 @@ class StackTest(common.HeatTestCase):
self.assertEqual(stack1.COMPLETE, stack1.status) self.assertEqual(stack1.COMPLETE, stack1.status)
self.assertEqual(stack1.CHECK, stack1.action) self.assertEqual(stack1.CHECK, stack1.action)
[self.assertTrue(res.handle_check.called) [self.assertTrue(res.handle_check.called)
for res in six.itervalues(stack1.resources)] for res in stack1.resources.values()]
self.assertNotIn('not fully supported', stack1.status_reason) self.assertNotIn('not fully supported', stack1.status_reason)
def test_check_not_supported(self): def test_check_not_supported(self):
@ -1283,7 +1282,7 @@ class StackTest(common.HeatTestCase):
exception.StackValidationFailed, stack.Stack, exception.StackValidationFailed, stack.Stack,
self.ctx, stack_name, self.tmpl) self.ctx, stack_name, self.tmpl)
self.assertIn("Invalid stack name %s must contain" % stack_name, self.assertIn("Invalid stack name %s must contain" % stack_name,
six.text_type(ex)) str(ex))
def test_stack_name_invalid_type(self): def test_stack_name_invalid_type(self):
stack_names = [{"bad": 123}, ["no", "lists"]] stack_names = [{"bad": 123}, ["no", "lists"]]
@ -1292,7 +1291,7 @@ class StackTest(common.HeatTestCase):
exception.StackValidationFailed, stack.Stack, exception.StackValidationFailed, stack.Stack,
self.ctx, stack_name, self.tmpl) self.ctx, stack_name, self.tmpl)
self.assertIn("Invalid stack name %s, must be a string" self.assertIn("Invalid stack name %s, must be a string"
% stack_name, six.text_type(ex)) % stack_name, str(ex))
def test_resource_state_get_att(self): def test_resource_state_get_att(self):
tmpl = { tmpl = {
@ -1536,7 +1535,7 @@ class StackTest(common.HeatTestCase):
self.stack = stack.Stack(self.ctx, 'creds_stack', self.tmpl) self.stack = stack.Stack(self.ctx, 'creds_stack', self.tmpl)
ex = self.assertRaises(exception.Error, self.stack.stored_context) ex = self.assertRaises(exception.Error, self.stack.stored_context)
expected_err = 'Attempt to use stored_context with no user_creds' expected_err = 'Attempt to use stored_context with no user_creds'
self.assertEqual(expected_err, six.text_type(ex)) self.assertEqual(expected_err, str(ex))
def test_store_gets_username_from_stack(self): def test_store_gets_username_from_stack(self):
self.stack = stack.Stack(self.ctx, 'username_stack', self.stack = stack.Stack(self.ctx, 'username_stack',
@ -1788,7 +1787,7 @@ class StackTest(common.HeatTestCase):
self.stack.outputs['Resource_attr'].get_value) self.stack.outputs['Resource_attr'].get_value)
self.assertIn('The Referenced Attribute (AResource Bar) is ' self.assertIn('The Referenced Attribute (AResource Bar) is '
'incorrect.', 'incorrect.',
six.text_type(ex)) str(ex))
self.stack.delete() self.stack.delete()
@ -1901,7 +1900,7 @@ class StackTest(common.HeatTestCase):
self.stack.validate) self.stack.validate)
self.assertIn('The specified reference "Resource" ' self.assertIn('The specified reference "Resource" '
'(in unknown) is incorrect.', six.text_type(ex)) '(in unknown) is incorrect.', str(ex))
def test_incorrect_outputs_incorrect_reference(self): def test_incorrect_outputs_incorrect_reference(self):
tmpl = template_format.parse(""" tmpl = template_format.parse("""
@ -1917,7 +1916,7 @@ class StackTest(common.HeatTestCase):
self.stack.validate) self.stack.validate)
self.assertIn('The specified reference "resource" ' self.assertIn('The specified reference "resource" '
'(in unknown) is incorrect.', six.text_type(ex)) '(in unknown) is incorrect.', str(ex))
def test_incorrect_outputs_cfn_missing_value(self): def test_incorrect_outputs_cfn_missing_value(self):
tmpl = template_format.parse(""" tmpl = template_format.parse("""
@ -1938,8 +1937,8 @@ class StackTest(common.HeatTestCase):
self.stack.validate) self.stack.validate)
self.assertIn('Each output definition must contain a Value key.', self.assertIn('Each output definition must contain a Value key.',
six.text_type(ex)) str(ex))
self.assertIn('Outputs.Resource_attr', six.text_type(ex)) self.assertIn('Outputs.Resource_attr', str(ex))
def test_incorrect_outputs_cfn_empty_value(self): def test_incorrect_outputs_cfn_empty_value(self):
tmpl = template_format.parse(""" tmpl = template_format.parse("""
@ -1993,9 +1992,9 @@ class StackTest(common.HeatTestCase):
ex = self.assertRaises(exception.StackValidationFailed, ex = self.assertRaises(exception.StackValidationFailed,
self.stack.validate) self.stack.validate)
self.assertIn('Found a %s instead' % six.text_type.__name__, self.assertIn('Found a %s instead' % str.__name__,
six.text_type(ex)) str(ex))
self.assertIn('Outputs.Resource_attr', six.text_type(ex)) self.assertIn('Outputs.Resource_attr', str(ex))
def test_prop_validate_value(self): def test_prop_validate_value(self):
tmpl = template_format.parse(""" tmpl = template_format.parse("""
@ -2013,7 +2012,7 @@ class StackTest(common.HeatTestCase):
self.stack.validate) self.stack.validate)
self.assertIn("'notanint' is not an integer", self.assertIn("'notanint' is not an integer",
six.text_type(ex)) str(ex))
self.stack.strict_validate = False self.stack.strict_validate = False
self.assertIsNone(self.stack.validate()) self.assertIsNone(self.stack.validate())
@ -2036,13 +2035,13 @@ class StackTest(common.HeatTestCase):
ex = self.assertRaises(exception.UserParameterMissing, ex = self.assertRaises(exception.UserParameterMissing,
self.stack.validate) self.stack.validate)
self.assertIn("The Parameter (aparam) was not provided", self.assertIn("The Parameter (aparam) was not provided",
six.text_type(ex)) str(ex))
self.stack.strict_validate = False self.stack.strict_validate = False
ex = self.assertRaises(exception.StackValidationFailed, ex = self.assertRaises(exception.StackValidationFailed,
self.stack.validate) self.stack.validate)
self.assertIn("The Parameter (aparam) was not provided", self.assertIn("The Parameter (aparam) was not provided",
six.text_type(ex)) str(ex))
self.assertIsNone(self.stack.validate(validate_res_tmpl_only=True)) self.assertIsNone(self.stack.validate(validate_res_tmpl_only=True))
@ -2063,21 +2062,21 @@ class StackTest(common.HeatTestCase):
self.stack.validate) self.stack.validate)
self.assertIn( self.assertIn(
"The specified reference \"noexist\" (in AResource) is incorrect", "The specified reference \"noexist\" (in AResource) is incorrect",
six.text_type(ex)) str(ex))
self.stack.strict_validate = False self.stack.strict_validate = False
ex = self.assertRaises(exception.InvalidTemplateReference, ex = self.assertRaises(exception.InvalidTemplateReference,
self.stack.validate) self.stack.validate)
self.assertIn( self.assertIn(
"The specified reference \"noexist\" (in AResource) is incorrect", "The specified reference \"noexist\" (in AResource) is incorrect",
six.text_type(ex)) str(ex))
ex = self.assertRaises(exception.InvalidTemplateReference, ex = self.assertRaises(exception.InvalidTemplateReference,
self.stack.validate, self.stack.validate,
validate_res_tmpl_only=True) validate_res_tmpl_only=True)
self.assertIn( self.assertIn(
"The specified reference \"noexist\" (in AResource) is incorrect", "The specified reference \"noexist\" (in AResource) is incorrect",
six.text_type(ex)) str(ex))
def test_validate_property_getatt(self): def test_validate_property_getatt(self):
tmpl = { tmpl = {
@ -2107,8 +2106,8 @@ class StackTest(common.HeatTestCase):
self.stack.validate) self.stack.validate)
self.assertIn("Parameter 'foo' is invalid: could not convert " self.assertIn("Parameter 'foo' is invalid: could not convert "
"string to float:", six.text_type(ex)) "string to float:", str(ex))
self.assertIn("abc", six.text_type(ex)) self.assertIn("abc", str(ex))
self.stack.strict_validate = False self.stack.strict_validate = False
self.assertIsNone(self.stack.validate()) self.assertIsNone(self.stack.validate())
@ -2131,8 +2130,8 @@ class StackTest(common.HeatTestCase):
ex = self.assertRaises(exception.StackValidationFailed, ex = self.assertRaises(exception.StackValidationFailed,
self.stack.validate) self.stack.validate)
self.assertIn('Found a list', six.text_type(ex)) self.assertIn('Found a list', str(ex))
self.assertIn('Outputs.Resource_attr', six.text_type(ex)) self.assertIn('Outputs.Resource_attr', str(ex))
def test_incorrect_deletion_policy(self): def test_incorrect_deletion_policy(self):
tmpl = template_format.parse(""" tmpl = template_format.parse("""
@ -2156,7 +2155,7 @@ class StackTest(common.HeatTestCase):
self.stack.validate) self.stack.validate)
self.assertIn('Invalid deletion policy "[1, 2]"', self.assertIn('Invalid deletion policy "[1, 2]"',
six.text_type(ex)) str(ex))
def test_deletion_policy_apply_ref(self): def test_deletion_policy_apply_ref(self):
tmpl = template_format.parse(""" tmpl = template_format.parse("""
@ -2226,7 +2225,7 @@ class StackTest(common.HeatTestCase):
self.stack.validate) self.stack.validate)
self.assertIn('Invalid deletion policy "[1, 2]', self.assertIn('Invalid deletion policy "[1, 2]',
six.text_type(ex)) str(ex))
def test_incorrect_outputs_hot_get_attr(self): def test_incorrect_outputs_hot_get_attr(self):
tmpl = {'heat_template_version': '2013-05-23', tmpl = {'heat_template_version': '2013-05-23',
@ -2764,7 +2763,7 @@ class StackTest(common.HeatTestCase):
stc._resources = {mock_res.name: mock_res} stc._resources = {mock_res.name: mock_res}
expected_exception = self.assertRaises(AssertionError, expected_exception = self.assertRaises(AssertionError,
stc.validate) stc.validate)
self.assertEqual(expected_msg, six.text_type(expected_exception)) self.assertEqual(expected_msg, str(expected_exception))
mock_dependency.validate.assert_called_once_with() mock_dependency.validate.assert_called_once_with()
tmpl = template_format.parse(""" tmpl = template_format.parse("""
@ -2777,7 +2776,7 @@ class StackTest(common.HeatTestCase):
template.Template(tmpl)) template.Template(tmpl))
func_val.side_effect = AssertionError(expected_msg) func_val.side_effect = AssertionError(expected_msg)
expected_exception = self.assertRaises(AssertionError, stc.validate) expected_exception = self.assertRaises(AssertionError, stc.validate)
self.assertEqual(expected_msg, six.text_type(expected_exception)) self.assertEqual(expected_msg, str(expected_exception))
@mock.patch.object(update, 'StackUpdate') @mock.patch.object(update, 'StackUpdate')
def test_update_task_exception(self, mock_stack_update): def test_update_task_exception(self, mock_stack_update):

View File

@ -12,7 +12,6 @@
# under the License. # under the License.
import itertools import itertools
import six
from heat.common import template_format from heat.common import template_format
from heat.engine import stack from heat.engine import stack
@ -229,7 +228,7 @@ class DepAttrsTest(common.HeatTestCase):
template.Template(self.parsed_tmpl)) template.Template(self.parsed_tmpl))
def test_dep_attrs(self): def test_dep_attrs(self):
for res in six.itervalues(self.stack): for res in self.stack.values():
definitions = (self.stack.defn.resource_definition(n) definitions = (self.stack.defn.resource_definition(n)
for n in self.parsed_tmpl['resources']) for n in self.parsed_tmpl['resources'])
self.assertEqual(self.expected[res.name], self.assertEqual(self.expected[res.name],
@ -237,7 +236,7 @@ class DepAttrsTest(common.HeatTestCase):
d.dep_attrs(res.name) for d in definitions))) d.dep_attrs(res.name) for d in definitions)))
def test_all_dep_attrs(self): def test_all_dep_attrs(self):
for res in six.itervalues(self.stack): for res in self.stack.values():
definitions = (self.stack.defn.resource_definition(n) definitions = (self.stack.defn.resource_definition(n)
for n in self.parsed_tmpl['resources']) for n in self.parsed_tmpl['resources'])
attrs = set(itertools.chain.from_iterable( attrs = set(itertools.chain.from_iterable(

View File

@ -19,7 +19,6 @@ import mock
from oslo_config import cfg from oslo_config import cfg
from oslo_messaging import exceptions as msg_exceptions from oslo_messaging import exceptions as msg_exceptions
from oslo_serialization import jsonutils from oslo_serialization import jsonutils
import six
from heat.common import exception from heat.common import exception
from heat.common import identifier from heat.common import identifier
@ -408,7 +407,7 @@ class StackResourceTest(StackResourceBaseTest):
'incorrect.') 'incorrect.')
exc = self.assertRaises(exception.StackValidationFailed, exc = self.assertRaises(exception.StackValidationFailed,
rsrc.validate) rsrc.validate)
self.assertEqual(raise_exc_msg, six.text_type(exc)) self.assertEqual(raise_exc_msg, str(exc))
def _test_validate_unknown_resource_type(self, stack_name, tmpl, def _test_validate_unknown_resource_type(self, stack_name, tmpl,
resource_name): resource_name):
@ -418,7 +417,7 @@ class StackResourceTest(StackResourceBaseTest):
exc = self.assertRaises(exception.StackValidationFailed, exc = self.assertRaises(exception.StackValidationFailed,
rsrc.validate) rsrc.validate)
self.assertIn(raise_exc_msg, six.text_type(exc)) self.assertIn(raise_exc_msg, str(exc))
def test_validate_resource_group(self): def test_validate_resource_group(self):
# test validate without nested template # test validate without nested template
@ -760,7 +759,7 @@ class StackResourceAttrTest(StackResourceBaseTest):
name = '%s-%s' % (self.parent_stack.name, self.parent_resource.name) name = '%s-%s' % (self.parent_stack.name, self.parent_resource.name)
exc = self.assertRaises(AssertionError, exc = self.assertRaises(AssertionError,
self.parent_resource.validate_nested_stack) self.parent_resource.validate_nested_stack)
self.assertEqual(expected_message, six.text_type(exc)) self.assertEqual(expected_message, str(exc))
mock_parse_nested.assert_called_once_with(name, 'foo', {}) mock_parse_nested.assert_called_once_with(name, 'foo', {})
@ -815,7 +814,7 @@ class StackResourceCheckCompleteTest(StackResourceBaseTest):
complete = getattr(self.parent_resource, complete = getattr(self.parent_resource,
'check_%s_complete' % self.action) 'check_%s_complete' % self.action)
exc = self.assertRaises(exception.ResourceFailure, complete, None) exc = self.assertRaises(exception.ResourceFailure, complete, None)
self.assertEqual(exp, six.text_type(exc)) self.assertEqual(exp, str(exc))
self.mock_status.assert_called_once_with( self.mock_status.assert_called_once_with(
self.parent_resource.context, self.parent_resource.resource_id) self.parent_resource.context, self.parent_resource.resource_id)
@ -882,7 +881,7 @@ class WithTemplateTest(StackResourceBaseTest):
def __eq__(self, other): def __eq__(self, other):
if getattr(self, 'match', None) is not None: if getattr(self, 'match', None) is not None:
return other == self.match return other == self.match
if not isinstance(other, six.integer_types): if not isinstance(other, int):
return False return False
self.match = other self.match = other

View File

@ -13,7 +13,6 @@
from keystoneauth1 import exceptions as kc_exceptions from keystoneauth1 import exceptions as kc_exceptions
import mock import mock
import six
from heat.common import exception from heat.common import exception
from heat.common import short_id from heat.common import short_id
@ -378,7 +377,7 @@ class StackUserTest(common.HeatTestCase):
self.assertEqual((rsrc.CREATE, rsrc.COMPLETE), rsrc.state) self.assertEqual((rsrc.CREATE, rsrc.COMPLETE), rsrc.state)
ex = self.assertRaises(ValueError, rsrc._user_token) ex = self.assertRaises(ValueError, rsrc._user_token)
expected = "Can't get user token without password" expected = "Can't get user token without password"
self.assertEqual(expected, six.text_type(ex)) self.assertEqual(expected, str(ex))
self.fc.stack_domain_user_token.assert_not_called() self.fc.stack_domain_user_token.assert_not_called()
def test_user_token_err_noproject(self): def test_user_token_err_noproject(self):
@ -390,4 +389,4 @@ class StackUserTest(common.HeatTestCase):
ex = self.assertRaises(ValueError, rsrc._user_token) ex = self.assertRaises(ValueError, rsrc._user_token)
expected = "Can't get user token, user not yet created" expected = "Can't get user token, user not yet created"
self.assertEqual(expected, six.text_type(ex)) self.assertEqual(expected, str(ex))

View File

@ -11,7 +11,6 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import six
from heat.engine import support from heat.engine import support
from heat.tests import common from heat.tests import common
@ -88,4 +87,4 @@ class SupportStatusTest(common.HeatTestCase):
ex = self.assertRaises(ValueError, ex = self.assertRaises(ValueError,
support.SupportStatus, previous_status='YARRR') support.SupportStatus, previous_status='YARRR')
self.assertEqual('previous_status must be SupportStatus ' self.assertEqual('previous_status must be SupportStatus '
'instead of %s' % str, six.text_type(ex)) 'instead of %s' % str, str(ex))

View File

@ -16,7 +16,6 @@ import hashlib
import json import json
import fixtures import fixtures
import six
from stevedore import extension from stevedore import extension
from heat.common import exception from heat.common import exception
@ -203,7 +202,7 @@ class TestTemplateVersion(common.HeatTestCase):
ex = self.assertRaises(exception.InvalidTemplateVersion, ex = self.assertRaises(exception.InvalidTemplateVersion,
template.get_version, tmpl, self.versions) template.get_version, tmpl, self.versions)
self.assertEqual('The template version is invalid: Template version ' self.assertEqual('The template version is invalid: Template version '
'was not provided', six.text_type(ex)) 'was not provided', str(ex))
def test_ambiguous_version(self): def test_ambiguous_version(self):
tmpl = { tmpl = {
@ -221,7 +220,7 @@ class ParserTest(common.HeatTestCase):
def test_list(self): def test_list(self):
raw = ['foo', 'bar', 'baz'] raw = ['foo', 'bar', 'baz']
parsed = join(raw) parsed = join(raw)
for i in six.moves.xrange(len(raw)): for i in range(len(raw)):
self.assertEqual(raw[i], parsed[i]) self.assertEqual(raw[i], parsed[i])
self.assertIsNot(raw, parsed) self.assertIsNot(raw, parsed)
@ -236,7 +235,7 @@ class ParserTest(common.HeatTestCase):
raw = {'foo': ['bar', 'baz'], 'blarg': 'wibble'} raw = {'foo': ['bar', 'baz'], 'blarg': 'wibble'}
parsed = join(raw) parsed = join(raw)
self.assertEqual(raw['blarg'], parsed['blarg']) self.assertEqual(raw['blarg'], parsed['blarg'])
for i in six.moves.xrange(len(raw['foo'])): for i in range(len(raw['foo'])):
self.assertEqual(raw['foo'][i], parsed['foo'][i]) self.assertEqual(raw['foo'][i], parsed['foo'][i])
self.assertIsNot(raw, parsed) self.assertIsNot(raw, parsed)
self.assertIsNot(raw['foo'], parsed['foo']) self.assertIsNot(raw['foo'], parsed['foo'])
@ -244,7 +243,7 @@ class ParserTest(common.HeatTestCase):
def test_list_dict(self): def test_list_dict(self):
raw = [{'foo': 'bar', 'blarg': 'wibble'}, 'baz', 'quux'] raw = [{'foo': 'bar', 'blarg': 'wibble'}, 'baz', 'quux']
parsed = join(raw) parsed = join(raw)
for i in six.moves.xrange(1, len(raw)): for i in range(1, len(raw)):
self.assertEqual(raw[i], parsed[i]) self.assertEqual(raw[i], parsed[i])
for k in raw[0]: for k in raw[0]:
self.assertEqual(raw[0][k], parsed[0][k]) self.assertEqual(raw[0][k], parsed[0][k])
@ -263,7 +262,7 @@ class ParserTest(common.HeatTestCase):
raw = [{'Fn::Join': [' ', ['foo', 'bar', 'baz']]}, 'blarg', 'wibble'] raw = [{'Fn::Join': [' ', ['foo', 'bar', 'baz']]}, 'blarg', 'wibble']
parsed = join(raw) parsed = join(raw)
self.assertEqual('foo bar baz', parsed[0]) self.assertEqual('foo bar baz', parsed[0])
for i in six.moves.xrange(1, len(raw)): for i in range(1, len(raw)):
self.assertEqual(raw[i], parsed[i]) self.assertEqual(raw[i], parsed[i])
self.assertIsNot(raw, parsed) self.assertIsNot(raw, parsed)
@ -326,23 +325,23 @@ class TestTemplateConditionParser(common.HeatTestCase):
stk = stack.Stack(self.ctx, 'test_condition_with_get_attr_func', tmpl) stk = stack.Stack(self.ctx, 'test_condition_with_get_attr_func', tmpl)
ex = self.assertRaises(exception.StackValidationFailed, ex = self.assertRaises(exception.StackValidationFailed,
tmpl.conditions, stk) tmpl.conditions, stk)
self.assertIn('"get_attr" is invalid', six.text_type(ex)) self.assertIn('"get_attr" is invalid', str(ex))
self.assertIn('conditions.prod_env.equals[1].get_attr', self.assertIn('conditions.prod_env.equals[1].get_attr',
six.text_type(ex)) str(ex))
# test with get_resource in top level of a condition # test with get_resource in top level of a condition
tmpl.t['conditions']['prod_env'] = {'get_resource': 'R1'} tmpl.t['conditions']['prod_env'] = {'get_resource': 'R1'}
stk = stack.Stack(self.ctx, 'test_condition_with_get_attr_func', tmpl) stk = stack.Stack(self.ctx, 'test_condition_with_get_attr_func', tmpl)
ex = self.assertRaises(exception.StackValidationFailed, ex = self.assertRaises(exception.StackValidationFailed,
tmpl.conditions, stk) tmpl.conditions, stk)
self.assertIn('"get_resource" is invalid', six.text_type(ex)) self.assertIn('"get_resource" is invalid', str(ex))
# test with get_attr in top level of a condition # test with get_attr in top level of a condition
tmpl.t['conditions']['prod_env'] = {'get_attr': [None, 'att']} tmpl.t['conditions']['prod_env'] = {'get_attr': [None, 'att']}
stk = stack.Stack(self.ctx, 'test_condition_with_get_attr_func', tmpl) stk = stack.Stack(self.ctx, 'test_condition_with_get_attr_func', tmpl)
ex = self.assertRaises(exception.StackValidationFailed, ex = self.assertRaises(exception.StackValidationFailed,
tmpl.conditions, stk) tmpl.conditions, stk)
self.assertIn('"get_attr" is invalid', six.text_type(ex)) self.assertIn('"get_attr" is invalid', str(ex))
def test_condition_resolved_not_boolean(self): def test_condition_resolved_not_boolean(self):
t = { t = {
@ -364,7 +363,7 @@ class TestTemplateConditionParser(common.HeatTestCase):
ex = self.assertRaises(exception.StackValidationFailed, ex = self.assertRaises(exception.StackValidationFailed,
conditions.is_enabled, 'prod_env') conditions.is_enabled, 'prod_env')
self.assertIn('The definition of condition "prod_env" is invalid', self.assertIn('The definition of condition "prod_env" is invalid',
six.text_type(ex)) str(ex))
def test_condition_reference_condition(self): def test_condition_reference_condition(self):
t = { t = {
@ -399,10 +398,10 @@ class TestTemplateConditionParser(common.HeatTestCase):
conds = tmpl.conditions(stk) conds = tmpl.conditions(stk)
ex = self.assertRaises(ValueError, conds.is_enabled, 'invalid_cd') ex = self.assertRaises(ValueError, conds.is_enabled, 'invalid_cd')
self.assertIn('Invalid condition "invalid_cd"', six.text_type(ex)) self.assertIn('Invalid condition "invalid_cd"', str(ex))
# test condition name is not string # test condition name is not string
ex = self.assertRaises(ValueError, conds.is_enabled, 111) ex = self.assertRaises(ValueError, conds.is_enabled, 111)
self.assertIn('Invalid condition "111"', six.text_type(ex)) self.assertIn('Invalid condition "111"', str(ex))
def test_res_condition_using_boolean(self): def test_res_condition_using_boolean(self):
tmpl = copy.deepcopy(self.tmpl) tmpl = copy.deepcopy(self.tmpl)
@ -422,14 +421,14 @@ class TestTemplateConditionParser(common.HeatTestCase):
self.tmpl.t['outputs']['foo']['condition'] = 'invalid_cd' self.tmpl.t['outputs']['foo']['condition'] = 'invalid_cd'
ex = self.assertRaises(exception.StackValidationFailed, ex = self.assertRaises(exception.StackValidationFailed,
lambda: stk.outputs) lambda: stk.outputs)
self.assertIn('Invalid condition "invalid_cd"', six.text_type(ex)) self.assertIn('Invalid condition "invalid_cd"', str(ex))
self.assertIn('outputs.foo.condition', six.text_type(ex)) self.assertIn('outputs.foo.condition', str(ex))
# test condition name is not string # test condition name is not string
self.tmpl.t['outputs']['foo']['condition'] = 222 self.tmpl.t['outputs']['foo']['condition'] = 222
ex = self.assertRaises(exception.StackValidationFailed, ex = self.assertRaises(exception.StackValidationFailed,
lambda: stk.outputs) lambda: stk.outputs)
self.assertIn('Invalid condition "222"', six.text_type(ex)) self.assertIn('Invalid condition "222"', str(ex))
self.assertIn('outputs.foo.condition', six.text_type(ex)) self.assertIn('outputs.foo.condition', str(ex))
def test_conditions_circular_ref(self): def test_conditions_circular_ref(self):
t = { t = {
@ -452,7 +451,7 @@ class TestTemplateConditionParser(common.HeatTestCase):
ex = self.assertRaises(exception.StackValidationFailed, ex = self.assertRaises(exception.StackValidationFailed,
conds.is_enabled, 'first_cond') conds.is_enabled, 'first_cond')
self.assertIn('Circular definition for condition "first_cond"', self.assertIn('Circular definition for condition "first_cond"',
six.text_type(ex)) str(ex))
def test_parse_output_condition_boolean(self): def test_parse_output_condition_boolean(self):
t = copy.deepcopy(self.tmpl.t) t = copy.deepcopy(self.tmpl.t)
@ -500,7 +499,7 @@ class TestTemplateValidate(common.HeatTestCase):
self.assertIsNone(tmpl.t_digest) self.assertIsNone(tmpl.t_digest)
tmpl.validate() tmpl.validate()
self.assertEqual( self.assertEqual(
hashlib.sha256(six.text_type(t).encode('utf-8')).hexdigest(), hashlib.sha256(str(t).encode('utf-8')).hexdigest(),
tmpl.t_digest, 'invalid template digest') tmpl.t_digest, 'invalid template digest')
def test_template_validate_cfn_good(self): def test_template_validate_cfn_good(self):
@ -556,7 +555,7 @@ class TestTemplateValidate(common.HeatTestCase):
tmpl = template.Template(t) tmpl = template.Template(t)
err = self.assertRaises(exception.InvalidTemplateSection, err = self.assertRaises(exception.InvalidTemplateSection,
tmpl.validate) tmpl.validate)
self.assertIn('Parameteers', six.text_type(err)) self.assertIn('Parameteers', str(err))
def test_template_validate_cfn_empty(self): def test_template_validate_cfn_empty(self):
t = template_format.parse(''' t = template_format.parse('''
@ -610,7 +609,7 @@ class TestTemplateValidate(common.HeatTestCase):
error = self.assertRaises(exception.StackValidationFailed, error = self.assertRaises(exception.StackValidationFailed,
tmpl.validate) tmpl.validate)
self.assertEqual('Each Resource must contain a Type key.', self.assertEqual('Each Resource must contain a Type key.',
six.text_type(error)) str(error))
def test_get_resources_no_type(self): def test_get_resources_no_type(self):
"""Test get resources with invalid key.""" """Test get resources with invalid key."""
@ -633,7 +632,7 @@ class TestTemplateValidate(common.HeatTestCase):
error = self.assertRaises(exception.StackValidationFailed, error = self.assertRaises(exception.StackValidationFailed,
tmpl.validate) tmpl.validate)
self.assertEqual('Each Resource must contain a Type key.', self.assertEqual('Each Resource must contain a Type key.',
six.text_type(error)) str(error))
def test_template_validate_hot_check_t_digest(self): def test_template_validate_hot_check_t_digest(self):
t = { t = {
@ -652,7 +651,7 @@ class TestTemplateValidate(common.HeatTestCase):
self.assertIsNone(tmpl.t_digest) self.assertIsNone(tmpl.t_digest)
tmpl.validate() tmpl.validate()
self.assertEqual(hashlib.sha256( self.assertEqual(hashlib.sha256(
six.text_type(t).encode('utf-8')).hexdigest(), str(t).encode('utf-8')).hexdigest(),
tmpl.t_digest, 'invalid template digest') tmpl.t_digest, 'invalid template digest')
def test_template_validate_hot_good(self): def test_template_validate_hot_good(self):
@ -688,7 +687,7 @@ class TestTemplateValidate(common.HeatTestCase):
tmpl = template.Template(t) tmpl = template.Template(t)
err = self.assertRaises(exception.InvalidTemplateSection, err = self.assertRaises(exception.InvalidTemplateSection,
tmpl.validate) tmpl.validate)
self.assertIn('parameteers', six.text_type(err)) self.assertIn('parameteers', str(err))
class TemplateTest(common.HeatTestCase): class TemplateTest(common.HeatTestCase):
@ -741,7 +740,7 @@ class TemplateTest(common.HeatTestCase):
'"heat_template_version: 2012-12-12". ' '"heat_template_version: 2012-12-12". '
'"heat_template_version" should be one of: %s' '"heat_template_version" should be one of: %s'
% ', '.join(valid_versions)) % ', '.join(valid_versions))
self.assertEqual(ex_error_msg, six.text_type(init_ex)) self.assertEqual(ex_error_msg, str(init_ex))
def test_invalid_version_not_in_hot_versions(self): def test_invalid_version_not_in_hot_versions(self):
invalid_hot_version_tmp = template_format.parse( invalid_hot_version_tmp = template_format.parse(
@ -761,7 +760,7 @@ class TemplateTest(common.HeatTestCase):
'"heat_template_version: 2012-12-12". ' '"heat_template_version: 2012-12-12". '
'"heat_template_version" should be ' '"heat_template_version" should be '
'one of: 2013-05-23, 2013-06-23') 'one of: 2013-05-23, 2013-06-23')
self.assertEqual(ex_error_msg, six.text_type(init_ex)) self.assertEqual(ex_error_msg, str(init_ex))
template._template_classes = temp_copy template._template_classes = temp_copy
def test_invalid_aws_version(self): def test_invalid_aws_version(self):
@ -774,7 +773,7 @@ class TemplateTest(common.HeatTestCase):
ex_error_msg = ('The template version is invalid: ' ex_error_msg = ('The template version is invalid: '
'"AWSTemplateFormatVersion: 2012-12-12". ' '"AWSTemplateFormatVersion: 2012-12-12". '
'"AWSTemplateFormatVersion" should be: 2010-09-09') '"AWSTemplateFormatVersion" should be: 2010-09-09')
self.assertEqual(ex_error_msg, six.text_type(init_ex)) self.assertEqual(ex_error_msg, str(init_ex))
def test_invalid_version_not_in_aws_versions(self): def test_invalid_version_not_in_aws_versions(self):
invalid_aws_version_tmp = template_format.parse( invalid_aws_version_tmp = template_format.parse(
@ -794,7 +793,7 @@ class TemplateTest(common.HeatTestCase):
'"AWSTemplateFormatVersion: 2012-12-12". ' '"AWSTemplateFormatVersion: 2012-12-12". '
'"AWSTemplateFormatVersion" should be ' '"AWSTemplateFormatVersion" should be '
'one of: 2010-09-09, 2011-06-23') 'one of: 2010-09-09, 2011-06-23')
self.assertEqual(ex_error_msg, six.text_type(init_ex)) self.assertEqual(ex_error_msg, str(init_ex))
template._template_classes = temp_copy template._template_classes = temp_copy
def test_invalid_heat_version(self): def test_invalid_heat_version(self):
@ -808,7 +807,7 @@ class TemplateTest(common.HeatTestCase):
ex_error_msg = ('The template version is invalid: ' ex_error_msg = ('The template version is invalid: '
'"HeatTemplateFormatVersion: 2010-09-09". ' '"HeatTemplateFormatVersion: 2010-09-09". '
'"HeatTemplateFormatVersion" should be: 2012-12-12') '"HeatTemplateFormatVersion" should be: 2012-12-12')
self.assertEqual(ex_error_msg, six.text_type(init_ex)) self.assertEqual(ex_error_msg, str(init_ex))
def test_invalid_version_not_in_heat_versions(self): def test_invalid_version_not_in_heat_versions(self):
invalid_heat_version_tmp = template_format.parse( invalid_heat_version_tmp = template_format.parse(
@ -829,7 +828,7 @@ class TemplateTest(common.HeatTestCase):
'"HeatTemplateFormatVersion: 2010-09-09". ' '"HeatTemplateFormatVersion: 2010-09-09". '
'"HeatTemplateFormatVersion" should be ' '"HeatTemplateFormatVersion" should be '
'one of: 2012-12-12, 2014-12-12') 'one of: 2012-12-12, 2014-12-12')
self.assertEqual(ex_error_msg, six.text_type(init_ex)) self.assertEqual(ex_error_msg, str(init_ex))
template._template_classes = temp_copy template._template_classes = temp_copy
@ -1013,12 +1012,12 @@ class TemplateTest(common.HeatTestCase):
error_msg = ('.Fn::Equals: Arguments to "Fn::Equals" must be ' error_msg = ('.Fn::Equals: Arguments to "Fn::Equals" must be '
'of the form: [value_1, value_2]') 'of the form: [value_1, value_2]')
self.assertIn(error_msg, six.text_type(exc)) self.assertIn(error_msg, str(exc))
# test invalid type # test invalid type
snippet = {'Fn::Equals': {"equal": False}} snippet = {'Fn::Equals': {"equal": False}}
exc = self.assertRaises(exception.StackValidationFailed, exc = self.assertRaises(exception.StackValidationFailed,
self.resolve_condition, snippet, tmpl) self.resolve_condition, snippet, tmpl)
self.assertIn(error_msg, six.text_type(exc)) self.assertIn(error_msg, str(exc))
def test_not(self): def test_not(self):
tpl = template_format.parse(''' tpl = template_format.parse('''
@ -1054,19 +1053,19 @@ class TemplateTest(common.HeatTestCase):
self.resolve_condition, snippet, tmpl, stk) self.resolve_condition, snippet, tmpl, stk)
error_msg = 'Invalid condition "invalid_arg"' error_msg = 'Invalid condition "invalid_arg"'
self.assertIn(error_msg, six.text_type(exc)) self.assertIn(error_msg, str(exc))
# test invalid type # test invalid type
snippet = {'Fn::Not': 'invalid'} snippet = {'Fn::Not': 'invalid'}
exc = self.assertRaises(exception.StackValidationFailed, exc = self.assertRaises(exception.StackValidationFailed,
self.resolve_condition, snippet, tmpl) self.resolve_condition, snippet, tmpl)
error_msg = 'Arguments to "Fn::Not" must be ' error_msg = 'Arguments to "Fn::Not" must be '
self.assertIn(error_msg, six.text_type(exc)) self.assertIn(error_msg, str(exc))
snippet = {'Fn::Not': ['cd1', 'cd2']} snippet = {'Fn::Not': ['cd1', 'cd2']}
exc = self.assertRaises(exception.StackValidationFailed, exc = self.assertRaises(exception.StackValidationFailed,
self.resolve_condition, snippet, tmpl) self.resolve_condition, snippet, tmpl)
error_msg = 'Arguments to "Fn::Not" must be ' error_msg = 'Arguments to "Fn::Not" must be '
self.assertIn(error_msg, six.text_type(exc)) self.assertIn(error_msg, str(exc))
def test_and(self): def test_and(self):
tpl = template_format.parse(''' tpl = template_format.parse('''
@ -1117,21 +1116,21 @@ class TemplateTest(common.HeatTestCase):
snippet = {'Fn::And': ['invalid_arg']} snippet = {'Fn::And': ['invalid_arg']}
exc = self.assertRaises(exception.StackValidationFailed, exc = self.assertRaises(exception.StackValidationFailed,
self.resolve_condition, snippet, tmpl) self.resolve_condition, snippet, tmpl)
self.assertIn(error_msg, six.text_type(exc)) self.assertIn(error_msg, str(exc))
error_msg = 'Arguments to "Fn::And" must be' error_msg = 'Arguments to "Fn::And" must be'
# test invalid type # test invalid type
snippet = {'Fn::And': 'invalid'} snippet = {'Fn::And': 'invalid'}
exc = self.assertRaises(exception.StackValidationFailed, exc = self.assertRaises(exception.StackValidationFailed,
self.resolve_condition, snippet, tmpl) self.resolve_condition, snippet, tmpl)
self.assertIn(error_msg, six.text_type(exc)) self.assertIn(error_msg, str(exc))
stk = stack.Stack(utils.dummy_context(), 'test_and_invalid', tmpl) stk = stack.Stack(utils.dummy_context(), 'test_and_invalid', tmpl)
snippet = {'Fn::And': ['cd1', True]} snippet = {'Fn::And': ['cd1', True]}
exc = self.assertRaises(ValueError, exc = self.assertRaises(ValueError,
self.resolve_condition, snippet, tmpl, stk) self.resolve_condition, snippet, tmpl, stk)
error_msg = 'Invalid condition "cd1"' error_msg = 'Invalid condition "cd1"'
self.assertIn(error_msg, six.text_type(exc)) self.assertIn(error_msg, str(exc))
def test_or(self): def test_or(self):
tpl = template_format.parse(''' tpl = template_format.parse('''
@ -1178,21 +1177,21 @@ class TemplateTest(common.HeatTestCase):
snippet = {'Fn::Or': ['invalid_arg']} snippet = {'Fn::Or': ['invalid_arg']}
exc = self.assertRaises(exception.StackValidationFailed, exc = self.assertRaises(exception.StackValidationFailed,
self.resolve_condition, snippet, tmpl) self.resolve_condition, snippet, tmpl)
self.assertIn(error_msg, six.text_type(exc)) self.assertIn(error_msg, str(exc))
error_msg = 'Arguments to "Fn::Or" must be' error_msg = 'Arguments to "Fn::Or" must be'
# test invalid type # test invalid type
snippet = {'Fn::Or': 'invalid'} snippet = {'Fn::Or': 'invalid'}
exc = self.assertRaises(exception.StackValidationFailed, exc = self.assertRaises(exception.StackValidationFailed,
self.resolve_condition, snippet, tmpl) self.resolve_condition, snippet, tmpl)
self.assertIn(error_msg, six.text_type(exc)) self.assertIn(error_msg, str(exc))
stk = stack.Stack(utils.dummy_context(), 'test_or_invalid', tmpl) stk = stack.Stack(utils.dummy_context(), 'test_or_invalid', tmpl)
snippet = {'Fn::Or': ['invalid_cd', True]} snippet = {'Fn::Or': ['invalid_cd', True]}
exc = self.assertRaises(ValueError, exc = self.assertRaises(ValueError,
self.resolve_condition, snippet, tmpl, stk) self.resolve_condition, snippet, tmpl, stk)
error_msg = 'Invalid condition "invalid_cd"' error_msg = 'Invalid condition "invalid_cd"'
self.assertIn(error_msg, six.text_type(exc)) self.assertIn(error_msg, str(exc))
def test_join(self): def test_join(self):
tmpl = template.Template(empty_template) tmpl = template.Template(empty_template)
@ -1359,7 +1358,7 @@ class TemplateTest(common.HeatTestCase):
template.Template(empty_template)) template.Template(empty_template))
error = self.assertRaises(exception.StackValidationFailed, error = self.assertRaises(exception.StackValidationFailed,
self.resolve, snippet, stk.t, stk) self.resolve, snippet, stk.t, stk)
self.assertIn(next(iter(snippet)), six.text_type(error)) self.assertIn(next(iter(snippet)), str(error))
def test_resource_facade_missing_deletion_policy(self): def test_resource_facade_missing_deletion_policy(self):
snippet = {'Fn::ResourceFacade': 'DeletionPolicy'} snippet = {'Fn::ResourceFacade': 'DeletionPolicy'}
@ -1390,7 +1389,7 @@ class TemplateTest(common.HeatTestCase):
}) })
self.assertEqual(expected_description, tmpl['Description']) self.assertEqual(expected_description, tmpl['Description'])
keyError = self.assertRaises(KeyError, tmpl.__getitem__, 'Parameters') keyError = self.assertRaises(KeyError, tmpl.__getitem__, 'Parameters')
self.assertIn("can not be accessed directly", six.text_type(keyError)) self.assertIn("can not be accessed directly", str(keyError))
def test_parameters_section_not_iterable(self): def test_parameters_section_not_iterable(self):
expected_description = "This can be accessed" expected_description = "This can be accessed"
@ -1451,7 +1450,7 @@ class TemplateTest(common.HeatTestCase):
empty = template.Template(copy.deepcopy(empty_template)) empty = template.Template(copy.deepcopy(empty_template))
stk = stack.Stack(self.ctx, 'test_stack', source) stk = stack.Stack(self.ctx, 'test_stack', source)
for defn in six.itervalues(source.outputs(stk)): for defn in source.outputs(stk).values():
empty.add_output(defn) empty.add_output(defn)
self.assertEqual(cfn_tpl['Outputs'], empty.t['Outputs']) self.assertEqual(cfn_tpl['Outputs'], empty.t['Outputs'])
@ -1649,7 +1648,7 @@ class TemplateFnErrorTest(common.HeatTestCase):
error = self.assertRaises(self.expect, error = self.assertRaises(self.expect,
resolve, resolve,
self.snippet) self.snippet)
self.assertIn(next(iter(self.snippet)), six.text_type(error)) self.assertIn(next(iter(self.snippet)), str(error))
class ResolveDataTest(common.HeatTestCase): class ResolveDataTest(common.HeatTestCase):
@ -1706,7 +1705,7 @@ class ResolveDataTest(common.HeatTestCase):
[' ', ['foo', 45]]}, 'baz']]} [' ', ['foo', 45]]}, 'baz']]}
error = self.assertRaises(TypeError, error = self.assertRaises(TypeError,
self.resolve, snippet) self.resolve, snippet)
self.assertIn('45', six.text_type(error)) self.assertIn('45', str(error))
def test_base64_replace(self): def test_base64_replace(self):
raw = {'Fn::Base64': {'Fn::Replace': [ raw = {'Fn::Base64': {'Fn::Replace': [

View File

@ -15,7 +15,6 @@ import os
import mock import mock
import re import re
import six
import yaml import yaml
from heat.common import config from heat.common import config
@ -94,7 +93,7 @@ class YamlMinimalTest(common.HeatTestCase):
parse_ex = self.assertRaises(ValueError, parse_ex = self.assertRaises(ValueError,
template_format.parse, template_format.parse,
tmpl_str) tmpl_str)
self.assertIn(msg_str, six.text_type(parse_ex)) self.assertIn(msg_str, str(parse_ex))
def test_long_yaml(self): def test_long_yaml(self):
template = {'HeatTemplateFormatVersion': '2012-12-12'} template = {'HeatTemplateFormatVersion': '2012-12-12'}
@ -110,7 +109,7 @@ class YamlMinimalTest(common.HeatTestCase):
'bytes) exceeds maximum allowed size (%(limit)s bytes).') % { 'bytes) exceeds maximum allowed size (%(limit)s bytes).') % {
'actual_len': len(str(long_yaml)), 'actual_len': len(str(long_yaml)),
'limit': config.cfg.CONF.max_template_size} 'limit': config.cfg.CONF.max_template_size}
self.assertEqual(msg, six.text_type(ex)) self.assertEqual(msg, str(ex))
def test_parse_no_version_format(self): def test_parse_no_version_format(self):
yaml = '' yaml = ''
@ -155,7 +154,7 @@ class YamlParseExceptions(common.HeatTestCase):
('parser', dict(raised_exception=yaml.parser.ParserError())), ('parser', dict(raised_exception=yaml.parser.ParserError())),
('reader', ('reader',
dict(raised_exception=yaml.reader.ReaderError( dict(raised_exception=yaml.reader.ReaderError(
'', 42, six.b('x'), '', ''))), '', 42, 'x'.encode('latin-1'), '', ''))),
] ]
def test_parse_to_value_exception(self): def test_parse_to_value_exception(self):
@ -169,7 +168,7 @@ class YamlParseExceptions(common.HeatTestCase):
'file://test.yaml') 'file://test.yaml')
self.assertIn('Error parsing template file://test.yaml', self.assertIn('Error parsing template file://test.yaml',
six.text_type(err)) str(err))
class JsonYamlResolvedCompareTest(common.HeatTestCase): class JsonYamlResolvedCompareTest(common.HeatTestCase):

View File

@ -13,7 +13,6 @@
import copy import copy
import mock import mock
import six
from heat.common import exception from heat.common import exception
from heat.engine.cfn import functions as cfn_funcs from heat.engine.cfn import functions as cfn_funcs
@ -94,7 +93,7 @@ class TestTranslationRule(common.HeatTestCase):
mock.ANY) mock.ANY)
self.assertEqual('There is no rule EatTheCookie. List of allowed ' self.assertEqual('There is no rule EatTheCookie. List of allowed '
'rules is: Add, Replace, Delete, Resolve.', 'rules is: Add, Replace, Delete, Resolve.',
six.text_type(exc)) str(exc))
exc = self.assertRaises(ValueError, exc = self.assertRaises(ValueError,
translation.TranslationRule, translation.TranslationRule,
@ -104,7 +103,7 @@ class TestTranslationRule(common.HeatTestCase):
'value') 'value')
self.assertEqual('"translation_path" should be non-empty list ' self.assertEqual('"translation_path" should be non-empty list '
'with path to translate.', 'with path to translate.',
six.text_type(exc)) str(exc))
exc = self.assertRaises(ValueError, exc = self.assertRaises(ValueError,
translation.TranslationRule, translation.TranslationRule,
@ -114,7 +113,7 @@ class TestTranslationRule(common.HeatTestCase):
mock.ANY) mock.ANY)
self.assertEqual('"translation_path" should be non-empty list ' self.assertEqual('"translation_path" should be non-empty list '
'with path to translate.', 'with path to translate.',
six.text_type(exc)) str(exc))
exc = self.assertRaises(ValueError, exc = self.assertRaises(ValueError,
translation.TranslationRule, translation.TranslationRule,
@ -126,7 +125,7 @@ class TestTranslationRule(common.HeatTestCase):
'some_path') 'some_path')
self.assertEqual('"value_path", "value" and "value_name" are ' self.assertEqual('"value_path", "value" and "value_name" are '
'mutually exclusive and cannot be specified ' 'mutually exclusive and cannot be specified '
'at the same time.', six.text_type(exc)) 'at the same time.', str(exc))
exc = self.assertRaises(ValueError, exc = self.assertRaises(ValueError,
translation.TranslationRule, translation.TranslationRule,
@ -135,7 +134,7 @@ class TestTranslationRule(common.HeatTestCase):
['any'], ['any'],
'value') 'value')
self.assertEqual('"value" must be list type when rule is Add.', self.assertEqual('"value" must be list type when rule is Add.',
six.text_type(exc)) str(exc))
def test_add_rule_exist(self): def test_add_rule_exist(self):
schema = { schema = {
@ -246,7 +245,7 @@ class TestTranslationRule(common.HeatTestCase):
ex = self.assertRaises(ValueError, tran.translate, 'far', 'tran') ex = self.assertRaises(ValueError, tran.translate, 'far', 'tran')
self.assertEqual('Incorrect translation rule using - cannot ' self.assertEqual('Incorrect translation rule using - cannot '
'resolve Add rule for non-list translation ' 'resolve Add rule for non-list translation '
'value "far".', six.text_type(ex)) 'value "far".', str(ex))
def test_replace_rule_map_exist(self): def test_replace_rule_map_exist(self):
schema = { schema = {
@ -446,7 +445,7 @@ class TestTranslationRule(common.HeatTestCase):
ex = self.assertRaises(exception.StackValidationFailed, ex = self.assertRaises(exception.StackValidationFailed,
tran.translate, 'bar', data['bar']) tran.translate, 'bar', data['bar'])
self.assertEqual('Cannot define the following properties at ' self.assertEqual('Cannot define the following properties at '
'the same time: bar, far', six.text_type(ex)) 'the same time: bar, far', str(ex))
def test_replace_rule_str_value_path(self): def test_replace_rule_str_value_path(self):
schema = { schema = {
@ -491,7 +490,7 @@ class TestTranslationRule(common.HeatTestCase):
exc = self.assertRaises(exception.StackValidationFailed, exc = self.assertRaises(exception.StackValidationFailed,
props.validate) props.validate)
self.assertEqual("Property error: bar: Value 'one' is not an integer", self.assertEqual("Property error: bar: Value 'one' is not an integer",
six.text_type(exc)) str(exc))
def test_delete_rule_list(self): def test_delete_rule_list(self):
schema = { schema = {