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:
parent
d7d3dcbb50
commit
062ce29a3b
@ -11,7 +11,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import six
|
||||
|
||||
from heat.common import exception
|
||||
from heat.common import template_format
|
||||
@ -87,7 +86,7 @@ class ResourceDefinitionTest(common.HeatTestCase):
|
||||
rd = self.make_me_one_with_everything()
|
||||
metadata = rd.metadata()
|
||||
self.assertEqual({'Baz': 'quux'}, metadata)
|
||||
self.assertIsInstance(metadata['Baz'], six.string_types)
|
||||
self.assertIsInstance(metadata['Baz'], str)
|
||||
|
||||
def test_dependencies_default(self):
|
||||
rd = rsrc_defn.ResourceDefinition('rsrc', 'SomeType')
|
||||
|
@ -15,8 +15,7 @@ import datetime
|
||||
|
||||
from keystoneauth1 import exceptions as kc_exceptions
|
||||
import mock
|
||||
import six
|
||||
from six.moves.urllib import parse as urlparse
|
||||
from urllib import parse as urlparse
|
||||
|
||||
from heat.common import exception
|
||||
from heat.common import template_format
|
||||
@ -624,7 +623,7 @@ class SignalTest(common.HeatTestCase):
|
||||
msg = 'Signal resource during %s is not supported.' % action
|
||||
exc = self.assertRaises(exception.NotSupported, rsrc.signal,
|
||||
details=err_metadata)
|
||||
self.assertEqual(msg, six.text_type(exc))
|
||||
self.assertEqual(msg, str(exc))
|
||||
|
||||
def test_signal_in_delete_state(self):
|
||||
# assert that we get the correct exception when calling a
|
||||
|
@ -22,7 +22,6 @@ import eventlet
|
||||
import fixtures
|
||||
import mock
|
||||
from oslo_config import cfg
|
||||
import six
|
||||
|
||||
from heat.common import context
|
||||
from heat.common import exception
|
||||
@ -938,7 +937,7 @@ class StackTest(common.HeatTestCase):
|
||||
def _mock_check(res):
|
||||
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
|
||||
|
||||
def test_check_supported(self):
|
||||
@ -950,7 +949,7 @@ class StackTest(common.HeatTestCase):
|
||||
self.assertEqual(stack1.COMPLETE, stack1.status)
|
||||
self.assertEqual(stack1.CHECK, stack1.action)
|
||||
[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)
|
||||
|
||||
def test_check_not_supported(self):
|
||||
@ -1283,7 +1282,7 @@ class StackTest(common.HeatTestCase):
|
||||
exception.StackValidationFailed, stack.Stack,
|
||||
self.ctx, stack_name, self.tmpl)
|
||||
self.assertIn("Invalid stack name %s must contain" % stack_name,
|
||||
six.text_type(ex))
|
||||
str(ex))
|
||||
|
||||
def test_stack_name_invalid_type(self):
|
||||
stack_names = [{"bad": 123}, ["no", "lists"]]
|
||||
@ -1292,7 +1291,7 @@ class StackTest(common.HeatTestCase):
|
||||
exception.StackValidationFailed, stack.Stack,
|
||||
self.ctx, stack_name, self.tmpl)
|
||||
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):
|
||||
tmpl = {
|
||||
@ -1536,7 +1535,7 @@ class StackTest(common.HeatTestCase):
|
||||
self.stack = stack.Stack(self.ctx, 'creds_stack', self.tmpl)
|
||||
ex = self.assertRaises(exception.Error, self.stack.stored_context)
|
||||
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):
|
||||
self.stack = stack.Stack(self.ctx, 'username_stack',
|
||||
@ -1788,7 +1787,7 @@ class StackTest(common.HeatTestCase):
|
||||
self.stack.outputs['Resource_attr'].get_value)
|
||||
self.assertIn('The Referenced Attribute (AResource Bar) is '
|
||||
'incorrect.',
|
||||
six.text_type(ex))
|
||||
str(ex))
|
||||
|
||||
self.stack.delete()
|
||||
|
||||
@ -1901,7 +1900,7 @@ class StackTest(common.HeatTestCase):
|
||||
self.stack.validate)
|
||||
|
||||
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):
|
||||
tmpl = template_format.parse("""
|
||||
@ -1917,7 +1916,7 @@ class StackTest(common.HeatTestCase):
|
||||
self.stack.validate)
|
||||
|
||||
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):
|
||||
tmpl = template_format.parse("""
|
||||
@ -1938,8 +1937,8 @@ class StackTest(common.HeatTestCase):
|
||||
self.stack.validate)
|
||||
|
||||
self.assertIn('Each output definition must contain a Value key.',
|
||||
six.text_type(ex))
|
||||
self.assertIn('Outputs.Resource_attr', six.text_type(ex))
|
||||
str(ex))
|
||||
self.assertIn('Outputs.Resource_attr', str(ex))
|
||||
|
||||
def test_incorrect_outputs_cfn_empty_value(self):
|
||||
tmpl = template_format.parse("""
|
||||
@ -1993,9 +1992,9 @@ class StackTest(common.HeatTestCase):
|
||||
ex = self.assertRaises(exception.StackValidationFailed,
|
||||
self.stack.validate)
|
||||
|
||||
self.assertIn('Found a %s instead' % six.text_type.__name__,
|
||||
six.text_type(ex))
|
||||
self.assertIn('Outputs.Resource_attr', six.text_type(ex))
|
||||
self.assertIn('Found a %s instead' % str.__name__,
|
||||
str(ex))
|
||||
self.assertIn('Outputs.Resource_attr', str(ex))
|
||||
|
||||
def test_prop_validate_value(self):
|
||||
tmpl = template_format.parse("""
|
||||
@ -2013,7 +2012,7 @@ class StackTest(common.HeatTestCase):
|
||||
self.stack.validate)
|
||||
|
||||
self.assertIn("'notanint' is not an integer",
|
||||
six.text_type(ex))
|
||||
str(ex))
|
||||
|
||||
self.stack.strict_validate = False
|
||||
self.assertIsNone(self.stack.validate())
|
||||
@ -2036,13 +2035,13 @@ class StackTest(common.HeatTestCase):
|
||||
ex = self.assertRaises(exception.UserParameterMissing,
|
||||
self.stack.validate)
|
||||
self.assertIn("The Parameter (aparam) was not provided",
|
||||
six.text_type(ex))
|
||||
str(ex))
|
||||
|
||||
self.stack.strict_validate = False
|
||||
ex = self.assertRaises(exception.StackValidationFailed,
|
||||
self.stack.validate)
|
||||
self.assertIn("The Parameter (aparam) was not provided",
|
||||
six.text_type(ex))
|
||||
str(ex))
|
||||
|
||||
self.assertIsNone(self.stack.validate(validate_res_tmpl_only=True))
|
||||
|
||||
@ -2063,21 +2062,21 @@ class StackTest(common.HeatTestCase):
|
||||
self.stack.validate)
|
||||
self.assertIn(
|
||||
"The specified reference \"noexist\" (in AResource) is incorrect",
|
||||
six.text_type(ex))
|
||||
str(ex))
|
||||
|
||||
self.stack.strict_validate = False
|
||||
ex = self.assertRaises(exception.InvalidTemplateReference,
|
||||
self.stack.validate)
|
||||
self.assertIn(
|
||||
"The specified reference \"noexist\" (in AResource) is incorrect",
|
||||
six.text_type(ex))
|
||||
str(ex))
|
||||
|
||||
ex = self.assertRaises(exception.InvalidTemplateReference,
|
||||
self.stack.validate,
|
||||
validate_res_tmpl_only=True)
|
||||
self.assertIn(
|
||||
"The specified reference \"noexist\" (in AResource) is incorrect",
|
||||
six.text_type(ex))
|
||||
str(ex))
|
||||
|
||||
def test_validate_property_getatt(self):
|
||||
tmpl = {
|
||||
@ -2107,8 +2106,8 @@ class StackTest(common.HeatTestCase):
|
||||
self.stack.validate)
|
||||
|
||||
self.assertIn("Parameter 'foo' is invalid: could not convert "
|
||||
"string to float:", six.text_type(ex))
|
||||
self.assertIn("abc", six.text_type(ex))
|
||||
"string to float:", str(ex))
|
||||
self.assertIn("abc", str(ex))
|
||||
|
||||
self.stack.strict_validate = False
|
||||
self.assertIsNone(self.stack.validate())
|
||||
@ -2131,8 +2130,8 @@ class StackTest(common.HeatTestCase):
|
||||
ex = self.assertRaises(exception.StackValidationFailed,
|
||||
self.stack.validate)
|
||||
|
||||
self.assertIn('Found a list', six.text_type(ex))
|
||||
self.assertIn('Outputs.Resource_attr', six.text_type(ex))
|
||||
self.assertIn('Found a list', str(ex))
|
||||
self.assertIn('Outputs.Resource_attr', str(ex))
|
||||
|
||||
def test_incorrect_deletion_policy(self):
|
||||
tmpl = template_format.parse("""
|
||||
@ -2156,7 +2155,7 @@ class StackTest(common.HeatTestCase):
|
||||
self.stack.validate)
|
||||
|
||||
self.assertIn('Invalid deletion policy "[1, 2]"',
|
||||
six.text_type(ex))
|
||||
str(ex))
|
||||
|
||||
def test_deletion_policy_apply_ref(self):
|
||||
tmpl = template_format.parse("""
|
||||
@ -2226,7 +2225,7 @@ class StackTest(common.HeatTestCase):
|
||||
self.stack.validate)
|
||||
|
||||
self.assertIn('Invalid deletion policy "[1, 2]',
|
||||
six.text_type(ex))
|
||||
str(ex))
|
||||
|
||||
def test_incorrect_outputs_hot_get_attr(self):
|
||||
tmpl = {'heat_template_version': '2013-05-23',
|
||||
@ -2764,7 +2763,7 @@ class StackTest(common.HeatTestCase):
|
||||
stc._resources = {mock_res.name: mock_res}
|
||||
expected_exception = self.assertRaises(AssertionError,
|
||||
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()
|
||||
|
||||
tmpl = template_format.parse("""
|
||||
@ -2777,7 +2776,7 @@ class StackTest(common.HeatTestCase):
|
||||
template.Template(tmpl))
|
||||
func_val.side_effect = AssertionError(expected_msg)
|
||||
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')
|
||||
def test_update_task_exception(self, mock_stack_update):
|
||||
|
@ -12,7 +12,6 @@
|
||||
# under the License.
|
||||
|
||||
import itertools
|
||||
import six
|
||||
|
||||
from heat.common import template_format
|
||||
from heat.engine import stack
|
||||
@ -229,7 +228,7 @@ class DepAttrsTest(common.HeatTestCase):
|
||||
template.Template(self.parsed_tmpl))
|
||||
|
||||
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)
|
||||
for n in self.parsed_tmpl['resources'])
|
||||
self.assertEqual(self.expected[res.name],
|
||||
@ -237,7 +236,7 @@ class DepAttrsTest(common.HeatTestCase):
|
||||
d.dep_attrs(res.name) for d in definitions)))
|
||||
|
||||
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)
|
||||
for n in self.parsed_tmpl['resources'])
|
||||
attrs = set(itertools.chain.from_iterable(
|
||||
|
@ -19,7 +19,6 @@ import mock
|
||||
from oslo_config import cfg
|
||||
from oslo_messaging import exceptions as msg_exceptions
|
||||
from oslo_serialization import jsonutils
|
||||
import six
|
||||
|
||||
from heat.common import exception
|
||||
from heat.common import identifier
|
||||
@ -408,7 +407,7 @@ class StackResourceTest(StackResourceBaseTest):
|
||||
'incorrect.')
|
||||
exc = self.assertRaises(exception.StackValidationFailed,
|
||||
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,
|
||||
resource_name):
|
||||
@ -418,7 +417,7 @@ class StackResourceTest(StackResourceBaseTest):
|
||||
|
||||
exc = self.assertRaises(exception.StackValidationFailed,
|
||||
rsrc.validate)
|
||||
self.assertIn(raise_exc_msg, six.text_type(exc))
|
||||
self.assertIn(raise_exc_msg, str(exc))
|
||||
|
||||
def test_validate_resource_group(self):
|
||||
# test validate without nested template
|
||||
@ -760,7 +759,7 @@ class StackResourceAttrTest(StackResourceBaseTest):
|
||||
name = '%s-%s' % (self.parent_stack.name, self.parent_resource.name)
|
||||
exc = self.assertRaises(AssertionError,
|
||||
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', {})
|
||||
|
||||
|
||||
@ -815,7 +814,7 @@ class StackResourceCheckCompleteTest(StackResourceBaseTest):
|
||||
complete = getattr(self.parent_resource,
|
||||
'check_%s_complete' % self.action)
|
||||
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.parent_resource.context, self.parent_resource.resource_id)
|
||||
|
||||
@ -882,7 +881,7 @@ class WithTemplateTest(StackResourceBaseTest):
|
||||
def __eq__(self, other):
|
||||
if getattr(self, 'match', None) is not None:
|
||||
return other == self.match
|
||||
if not isinstance(other, six.integer_types):
|
||||
if not isinstance(other, int):
|
||||
return False
|
||||
|
||||
self.match = other
|
||||
|
@ -13,7 +13,6 @@
|
||||
|
||||
from keystoneauth1 import exceptions as kc_exceptions
|
||||
import mock
|
||||
import six
|
||||
|
||||
from heat.common import exception
|
||||
from heat.common import short_id
|
||||
@ -378,7 +377,7 @@ class StackUserTest(common.HeatTestCase):
|
||||
self.assertEqual((rsrc.CREATE, rsrc.COMPLETE), rsrc.state)
|
||||
ex = self.assertRaises(ValueError, rsrc._user_token)
|
||||
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()
|
||||
|
||||
def test_user_token_err_noproject(self):
|
||||
@ -390,4 +389,4 @@ class StackUserTest(common.HeatTestCase):
|
||||
|
||||
ex = self.assertRaises(ValueError, rsrc._user_token)
|
||||
expected = "Can't get user token, user not yet created"
|
||||
self.assertEqual(expected, six.text_type(ex))
|
||||
self.assertEqual(expected, str(ex))
|
||||
|
@ -11,7 +11,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import six
|
||||
|
||||
from heat.engine import support
|
||||
from heat.tests import common
|
||||
@ -88,4 +87,4 @@ class SupportStatusTest(common.HeatTestCase):
|
||||
ex = self.assertRaises(ValueError,
|
||||
support.SupportStatus, previous_status='YARRR')
|
||||
self.assertEqual('previous_status must be SupportStatus '
|
||||
'instead of %s' % str, six.text_type(ex))
|
||||
'instead of %s' % str, str(ex))
|
||||
|
@ -16,7 +16,6 @@ import hashlib
|
||||
import json
|
||||
|
||||
import fixtures
|
||||
import six
|
||||
from stevedore import extension
|
||||
|
||||
from heat.common import exception
|
||||
@ -203,7 +202,7 @@ class TestTemplateVersion(common.HeatTestCase):
|
||||
ex = self.assertRaises(exception.InvalidTemplateVersion,
|
||||
template.get_version, tmpl, self.versions)
|
||||
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):
|
||||
tmpl = {
|
||||
@ -221,7 +220,7 @@ class ParserTest(common.HeatTestCase):
|
||||
def test_list(self):
|
||||
raw = ['foo', 'bar', 'baz']
|
||||
parsed = join(raw)
|
||||
for i in six.moves.xrange(len(raw)):
|
||||
for i in range(len(raw)):
|
||||
self.assertEqual(raw[i], parsed[i])
|
||||
self.assertIsNot(raw, parsed)
|
||||
|
||||
@ -236,7 +235,7 @@ class ParserTest(common.HeatTestCase):
|
||||
raw = {'foo': ['bar', 'baz'], 'blarg': 'wibble'}
|
||||
parsed = join(raw)
|
||||
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.assertIsNot(raw, parsed)
|
||||
self.assertIsNot(raw['foo'], parsed['foo'])
|
||||
@ -244,7 +243,7 @@ class ParserTest(common.HeatTestCase):
|
||||
def test_list_dict(self):
|
||||
raw = [{'foo': 'bar', 'blarg': 'wibble'}, 'baz', 'quux']
|
||||
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])
|
||||
for k in raw[0]:
|
||||
self.assertEqual(raw[0][k], parsed[0][k])
|
||||
@ -263,7 +262,7 @@ class ParserTest(common.HeatTestCase):
|
||||
raw = [{'Fn::Join': [' ', ['foo', 'bar', 'baz']]}, 'blarg', 'wibble']
|
||||
parsed = join(raw)
|
||||
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.assertIsNot(raw, parsed)
|
||||
|
||||
@ -326,23 +325,23 @@ class TestTemplateConditionParser(common.HeatTestCase):
|
||||
stk = stack.Stack(self.ctx, 'test_condition_with_get_attr_func', tmpl)
|
||||
ex = self.assertRaises(exception.StackValidationFailed,
|
||||
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',
|
||||
six.text_type(ex))
|
||||
str(ex))
|
||||
|
||||
# test with get_resource in top level of a condition
|
||||
tmpl.t['conditions']['prod_env'] = {'get_resource': 'R1'}
|
||||
stk = stack.Stack(self.ctx, 'test_condition_with_get_attr_func', tmpl)
|
||||
ex = self.assertRaises(exception.StackValidationFailed,
|
||||
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
|
||||
tmpl.t['conditions']['prod_env'] = {'get_attr': [None, 'att']}
|
||||
stk = stack.Stack(self.ctx, 'test_condition_with_get_attr_func', tmpl)
|
||||
ex = self.assertRaises(exception.StackValidationFailed,
|
||||
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):
|
||||
t = {
|
||||
@ -364,7 +363,7 @@ class TestTemplateConditionParser(common.HeatTestCase):
|
||||
ex = self.assertRaises(exception.StackValidationFailed,
|
||||
conditions.is_enabled, 'prod_env')
|
||||
self.assertIn('The definition of condition "prod_env" is invalid',
|
||||
six.text_type(ex))
|
||||
str(ex))
|
||||
|
||||
def test_condition_reference_condition(self):
|
||||
t = {
|
||||
@ -399,10 +398,10 @@ class TestTemplateConditionParser(common.HeatTestCase):
|
||||
|
||||
conds = tmpl.conditions(stk)
|
||||
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
|
||||
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):
|
||||
tmpl = copy.deepcopy(self.tmpl)
|
||||
@ -422,14 +421,14 @@ class TestTemplateConditionParser(common.HeatTestCase):
|
||||
self.tmpl.t['outputs']['foo']['condition'] = 'invalid_cd'
|
||||
ex = self.assertRaises(exception.StackValidationFailed,
|
||||
lambda: stk.outputs)
|
||||
self.assertIn('Invalid condition "invalid_cd"', six.text_type(ex))
|
||||
self.assertIn('outputs.foo.condition', six.text_type(ex))
|
||||
self.assertIn('Invalid condition "invalid_cd"', str(ex))
|
||||
self.assertIn('outputs.foo.condition', str(ex))
|
||||
# test condition name is not string
|
||||
self.tmpl.t['outputs']['foo']['condition'] = 222
|
||||
ex = self.assertRaises(exception.StackValidationFailed,
|
||||
lambda: stk.outputs)
|
||||
self.assertIn('Invalid condition "222"', six.text_type(ex))
|
||||
self.assertIn('outputs.foo.condition', six.text_type(ex))
|
||||
self.assertIn('Invalid condition "222"', str(ex))
|
||||
self.assertIn('outputs.foo.condition', str(ex))
|
||||
|
||||
def test_conditions_circular_ref(self):
|
||||
t = {
|
||||
@ -452,7 +451,7 @@ class TestTemplateConditionParser(common.HeatTestCase):
|
||||
ex = self.assertRaises(exception.StackValidationFailed,
|
||||
conds.is_enabled, 'first_cond')
|
||||
self.assertIn('Circular definition for condition "first_cond"',
|
||||
six.text_type(ex))
|
||||
str(ex))
|
||||
|
||||
def test_parse_output_condition_boolean(self):
|
||||
t = copy.deepcopy(self.tmpl.t)
|
||||
@ -500,7 +499,7 @@ class TestTemplateValidate(common.HeatTestCase):
|
||||
self.assertIsNone(tmpl.t_digest)
|
||||
tmpl.validate()
|
||||
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')
|
||||
|
||||
def test_template_validate_cfn_good(self):
|
||||
@ -556,7 +555,7 @@ class TestTemplateValidate(common.HeatTestCase):
|
||||
tmpl = template.Template(t)
|
||||
err = self.assertRaises(exception.InvalidTemplateSection,
|
||||
tmpl.validate)
|
||||
self.assertIn('Parameteers', six.text_type(err))
|
||||
self.assertIn('Parameteers', str(err))
|
||||
|
||||
def test_template_validate_cfn_empty(self):
|
||||
t = template_format.parse('''
|
||||
@ -610,7 +609,7 @@ class TestTemplateValidate(common.HeatTestCase):
|
||||
error = self.assertRaises(exception.StackValidationFailed,
|
||||
tmpl.validate)
|
||||
self.assertEqual('Each Resource must contain a Type key.',
|
||||
six.text_type(error))
|
||||
str(error))
|
||||
|
||||
def test_get_resources_no_type(self):
|
||||
"""Test get resources with invalid key."""
|
||||
@ -633,7 +632,7 @@ class TestTemplateValidate(common.HeatTestCase):
|
||||
error = self.assertRaises(exception.StackValidationFailed,
|
||||
tmpl.validate)
|
||||
self.assertEqual('Each Resource must contain a Type key.',
|
||||
six.text_type(error))
|
||||
str(error))
|
||||
|
||||
def test_template_validate_hot_check_t_digest(self):
|
||||
t = {
|
||||
@ -652,7 +651,7 @@ class TestTemplateValidate(common.HeatTestCase):
|
||||
self.assertIsNone(tmpl.t_digest)
|
||||
tmpl.validate()
|
||||
self.assertEqual(hashlib.sha256(
|
||||
six.text_type(t).encode('utf-8')).hexdigest(),
|
||||
str(t).encode('utf-8')).hexdigest(),
|
||||
tmpl.t_digest, 'invalid template digest')
|
||||
|
||||
def test_template_validate_hot_good(self):
|
||||
@ -688,7 +687,7 @@ class TestTemplateValidate(common.HeatTestCase):
|
||||
tmpl = template.Template(t)
|
||||
err = self.assertRaises(exception.InvalidTemplateSection,
|
||||
tmpl.validate)
|
||||
self.assertIn('parameteers', six.text_type(err))
|
||||
self.assertIn('parameteers', str(err))
|
||||
|
||||
|
||||
class TemplateTest(common.HeatTestCase):
|
||||
@ -741,7 +740,7 @@ class TemplateTest(common.HeatTestCase):
|
||||
'"heat_template_version: 2012-12-12". '
|
||||
'"heat_template_version" should be one of: %s'
|
||||
% ', '.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):
|
||||
invalid_hot_version_tmp = template_format.parse(
|
||||
@ -761,7 +760,7 @@ class TemplateTest(common.HeatTestCase):
|
||||
'"heat_template_version: 2012-12-12". '
|
||||
'"heat_template_version" should be '
|
||||
'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
|
||||
|
||||
def test_invalid_aws_version(self):
|
||||
@ -774,7 +773,7 @@ class TemplateTest(common.HeatTestCase):
|
||||
ex_error_msg = ('The template version is invalid: '
|
||||
'"AWSTemplateFormatVersion: 2012-12-12". '
|
||||
'"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):
|
||||
invalid_aws_version_tmp = template_format.parse(
|
||||
@ -794,7 +793,7 @@ class TemplateTest(common.HeatTestCase):
|
||||
'"AWSTemplateFormatVersion: 2012-12-12". '
|
||||
'"AWSTemplateFormatVersion" should be '
|
||||
'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
|
||||
|
||||
def test_invalid_heat_version(self):
|
||||
@ -808,7 +807,7 @@ class TemplateTest(common.HeatTestCase):
|
||||
ex_error_msg = ('The template version is invalid: '
|
||||
'"HeatTemplateFormatVersion: 2010-09-09". '
|
||||
'"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):
|
||||
invalid_heat_version_tmp = template_format.parse(
|
||||
@ -829,7 +828,7 @@ class TemplateTest(common.HeatTestCase):
|
||||
'"HeatTemplateFormatVersion: 2010-09-09". '
|
||||
'"HeatTemplateFormatVersion" should be '
|
||||
'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
|
||||
|
||||
@ -1013,12 +1012,12 @@ class TemplateTest(common.HeatTestCase):
|
||||
|
||||
error_msg = ('.Fn::Equals: Arguments to "Fn::Equals" must be '
|
||||
'of the form: [value_1, value_2]')
|
||||
self.assertIn(error_msg, six.text_type(exc))
|
||||
self.assertIn(error_msg, str(exc))
|
||||
# test invalid type
|
||||
snippet = {'Fn::Equals': {"equal": False}}
|
||||
exc = self.assertRaises(exception.StackValidationFailed,
|
||||
self.resolve_condition, snippet, tmpl)
|
||||
self.assertIn(error_msg, six.text_type(exc))
|
||||
self.assertIn(error_msg, str(exc))
|
||||
|
||||
def test_not(self):
|
||||
tpl = template_format.parse('''
|
||||
@ -1054,19 +1053,19 @@ class TemplateTest(common.HeatTestCase):
|
||||
self.resolve_condition, snippet, tmpl, stk)
|
||||
|
||||
error_msg = 'Invalid condition "invalid_arg"'
|
||||
self.assertIn(error_msg, six.text_type(exc))
|
||||
self.assertIn(error_msg, str(exc))
|
||||
# test invalid type
|
||||
snippet = {'Fn::Not': 'invalid'}
|
||||
exc = self.assertRaises(exception.StackValidationFailed,
|
||||
self.resolve_condition, snippet, tmpl)
|
||||
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']}
|
||||
exc = self.assertRaises(exception.StackValidationFailed,
|
||||
self.resolve_condition, snippet, tmpl)
|
||||
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):
|
||||
tpl = template_format.parse('''
|
||||
@ -1117,21 +1116,21 @@ class TemplateTest(common.HeatTestCase):
|
||||
snippet = {'Fn::And': ['invalid_arg']}
|
||||
exc = self.assertRaises(exception.StackValidationFailed,
|
||||
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'
|
||||
# test invalid type
|
||||
snippet = {'Fn::And': 'invalid'}
|
||||
exc = self.assertRaises(exception.StackValidationFailed,
|
||||
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)
|
||||
snippet = {'Fn::And': ['cd1', True]}
|
||||
exc = self.assertRaises(ValueError,
|
||||
self.resolve_condition, snippet, tmpl, stk)
|
||||
error_msg = 'Invalid condition "cd1"'
|
||||
self.assertIn(error_msg, six.text_type(exc))
|
||||
self.assertIn(error_msg, str(exc))
|
||||
|
||||
def test_or(self):
|
||||
tpl = template_format.parse('''
|
||||
@ -1178,21 +1177,21 @@ class TemplateTest(common.HeatTestCase):
|
||||
snippet = {'Fn::Or': ['invalid_arg']}
|
||||
exc = self.assertRaises(exception.StackValidationFailed,
|
||||
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'
|
||||
# test invalid type
|
||||
snippet = {'Fn::Or': 'invalid'}
|
||||
exc = self.assertRaises(exception.StackValidationFailed,
|
||||
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)
|
||||
snippet = {'Fn::Or': ['invalid_cd', True]}
|
||||
exc = self.assertRaises(ValueError,
|
||||
self.resolve_condition, snippet, tmpl, stk)
|
||||
error_msg = 'Invalid condition "invalid_cd"'
|
||||
self.assertIn(error_msg, six.text_type(exc))
|
||||
self.assertIn(error_msg, str(exc))
|
||||
|
||||
def test_join(self):
|
||||
tmpl = template.Template(empty_template)
|
||||
@ -1359,7 +1358,7 @@ class TemplateTest(common.HeatTestCase):
|
||||
template.Template(empty_template))
|
||||
error = self.assertRaises(exception.StackValidationFailed,
|
||||
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):
|
||||
snippet = {'Fn::ResourceFacade': 'DeletionPolicy'}
|
||||
@ -1390,7 +1389,7 @@ class TemplateTest(common.HeatTestCase):
|
||||
})
|
||||
self.assertEqual(expected_description, tmpl['Description'])
|
||||
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):
|
||||
expected_description = "This can be accessed"
|
||||
@ -1451,7 +1450,7 @@ class TemplateTest(common.HeatTestCase):
|
||||
empty = template.Template(copy.deepcopy(empty_template))
|
||||
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)
|
||||
|
||||
self.assertEqual(cfn_tpl['Outputs'], empty.t['Outputs'])
|
||||
@ -1649,7 +1648,7 @@ class TemplateFnErrorTest(common.HeatTestCase):
|
||||
error = self.assertRaises(self.expect,
|
||||
resolve,
|
||||
self.snippet)
|
||||
self.assertIn(next(iter(self.snippet)), six.text_type(error))
|
||||
self.assertIn(next(iter(self.snippet)), str(error))
|
||||
|
||||
|
||||
class ResolveDataTest(common.HeatTestCase):
|
||||
@ -1706,7 +1705,7 @@ class ResolveDataTest(common.HeatTestCase):
|
||||
[' ', ['foo', 45]]}, 'baz']]}
|
||||
error = self.assertRaises(TypeError,
|
||||
self.resolve, snippet)
|
||||
self.assertIn('45', six.text_type(error))
|
||||
self.assertIn('45', str(error))
|
||||
|
||||
def test_base64_replace(self):
|
||||
raw = {'Fn::Base64': {'Fn::Replace': [
|
||||
|
@ -15,7 +15,6 @@ import os
|
||||
|
||||
import mock
|
||||
import re
|
||||
import six
|
||||
import yaml
|
||||
|
||||
from heat.common import config
|
||||
@ -94,7 +93,7 @@ class YamlMinimalTest(common.HeatTestCase):
|
||||
parse_ex = self.assertRaises(ValueError,
|
||||
template_format.parse,
|
||||
tmpl_str)
|
||||
self.assertIn(msg_str, six.text_type(parse_ex))
|
||||
self.assertIn(msg_str, str(parse_ex))
|
||||
|
||||
def test_long_yaml(self):
|
||||
template = {'HeatTemplateFormatVersion': '2012-12-12'}
|
||||
@ -110,7 +109,7 @@ class YamlMinimalTest(common.HeatTestCase):
|
||||
'bytes) exceeds maximum allowed size (%(limit)s bytes).') % {
|
||||
'actual_len': len(str(long_yaml)),
|
||||
'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):
|
||||
yaml = ''
|
||||
@ -155,7 +154,7 @@ class YamlParseExceptions(common.HeatTestCase):
|
||||
('parser', dict(raised_exception=yaml.parser.ParserError())),
|
||||
('reader',
|
||||
dict(raised_exception=yaml.reader.ReaderError(
|
||||
'', 42, six.b('x'), '', ''))),
|
||||
'', 42, 'x'.encode('latin-1'), '', ''))),
|
||||
]
|
||||
|
||||
def test_parse_to_value_exception(self):
|
||||
@ -169,7 +168,7 @@ class YamlParseExceptions(common.HeatTestCase):
|
||||
'file://test.yaml')
|
||||
|
||||
self.assertIn('Error parsing template file://test.yaml',
|
||||
six.text_type(err))
|
||||
str(err))
|
||||
|
||||
|
||||
class JsonYamlResolvedCompareTest(common.HeatTestCase):
|
||||
|
@ -13,7 +13,6 @@
|
||||
|
||||
import copy
|
||||
import mock
|
||||
import six
|
||||
|
||||
from heat.common import exception
|
||||
from heat.engine.cfn import functions as cfn_funcs
|
||||
@ -94,7 +93,7 @@ class TestTranslationRule(common.HeatTestCase):
|
||||
mock.ANY)
|
||||
self.assertEqual('There is no rule EatTheCookie. List of allowed '
|
||||
'rules is: Add, Replace, Delete, Resolve.',
|
||||
six.text_type(exc))
|
||||
str(exc))
|
||||
|
||||
exc = self.assertRaises(ValueError,
|
||||
translation.TranslationRule,
|
||||
@ -104,7 +103,7 @@ class TestTranslationRule(common.HeatTestCase):
|
||||
'value')
|
||||
self.assertEqual('"translation_path" should be non-empty list '
|
||||
'with path to translate.',
|
||||
six.text_type(exc))
|
||||
str(exc))
|
||||
|
||||
exc = self.assertRaises(ValueError,
|
||||
translation.TranslationRule,
|
||||
@ -114,7 +113,7 @@ class TestTranslationRule(common.HeatTestCase):
|
||||
mock.ANY)
|
||||
self.assertEqual('"translation_path" should be non-empty list '
|
||||
'with path to translate.',
|
||||
six.text_type(exc))
|
||||
str(exc))
|
||||
|
||||
exc = self.assertRaises(ValueError,
|
||||
translation.TranslationRule,
|
||||
@ -126,7 +125,7 @@ class TestTranslationRule(common.HeatTestCase):
|
||||
'some_path')
|
||||
self.assertEqual('"value_path", "value" and "value_name" are '
|
||||
'mutually exclusive and cannot be specified '
|
||||
'at the same time.', six.text_type(exc))
|
||||
'at the same time.', str(exc))
|
||||
|
||||
exc = self.assertRaises(ValueError,
|
||||
translation.TranslationRule,
|
||||
@ -135,7 +134,7 @@ class TestTranslationRule(common.HeatTestCase):
|
||||
['any'],
|
||||
'value')
|
||||
self.assertEqual('"value" must be list type when rule is Add.',
|
||||
six.text_type(exc))
|
||||
str(exc))
|
||||
|
||||
def test_add_rule_exist(self):
|
||||
schema = {
|
||||
@ -246,7 +245,7 @@ class TestTranslationRule(common.HeatTestCase):
|
||||
ex = self.assertRaises(ValueError, tran.translate, 'far', 'tran')
|
||||
self.assertEqual('Incorrect translation rule using - cannot '
|
||||
'resolve Add rule for non-list translation '
|
||||
'value "far".', six.text_type(ex))
|
||||
'value "far".', str(ex))
|
||||
|
||||
def test_replace_rule_map_exist(self):
|
||||
schema = {
|
||||
@ -446,7 +445,7 @@ class TestTranslationRule(common.HeatTestCase):
|
||||
ex = self.assertRaises(exception.StackValidationFailed,
|
||||
tran.translate, 'bar', data['bar'])
|
||||
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):
|
||||
schema = {
|
||||
@ -491,7 +490,7 @@ class TestTranslationRule(common.HeatTestCase):
|
||||
exc = self.assertRaises(exception.StackValidationFailed,
|
||||
props.validate)
|
||||
self.assertEqual("Property error: bar: Value 'one' is not an integer",
|
||||
six.text_type(exc))
|
||||
str(exc))
|
||||
|
||||
def test_delete_rule_list(self):
|
||||
schema = {
|
||||
|
Loading…
Reference in New Issue
Block a user