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 25 of a serie of 28 patches Change-Id: I62f75179047c901c545bdd3efba80e4a8088bb5e
This commit is contained in:
parent
e8e32c6ed3
commit
ea89a2a08c
@ -15,7 +15,6 @@ import json
|
||||
from keystoneauth1 import loading as ks_loading
|
||||
from keystoneauth1 import session
|
||||
import mock
|
||||
import six
|
||||
|
||||
from heat.common import auth_plugin
|
||||
from heat.common import config
|
||||
@ -80,7 +79,7 @@ class TestAuthPlugin(common.HeatTestCase):
|
||||
ValueError, auth_plugin.parse_auth_credential_to_dict, credential)
|
||||
self.assertEqual("Missing key in auth information, the correct "
|
||||
"format contains [\'auth_type\', \'auth\'].",
|
||||
six.text_type(error))
|
||||
str(error))
|
||||
|
||||
def test_parse_auth_credential_to_dict_with_json_error(self):
|
||||
credential = (
|
||||
@ -93,4 +92,4 @@ class TestAuthPlugin(common.HeatTestCase):
|
||||
ValueError, auth_plugin.parse_auth_credential_to_dict, credential)
|
||||
error_msg = ('Failed to parse credential, please check your Stack '
|
||||
'Credential format.')
|
||||
self.assertEqual(error_msg, six.text_type(error))
|
||||
self.assertEqual(error_msg, str(error))
|
||||
|
@ -19,7 +19,6 @@ import datetime
|
||||
|
||||
from lxml import etree
|
||||
from oslo_serialization import jsonutils as json
|
||||
import six
|
||||
import webob
|
||||
|
||||
from heat.common import serializers
|
||||
@ -111,9 +110,9 @@ class XMLResponseSerializerTest(common.HeatTestCase):
|
||||
])])
|
||||
]))
|
||||
])
|
||||
expected = six.b('<aresponse><is_public>True</is_public>'
|
||||
'<name><member><name1>test</name1></member></name>'
|
||||
'</aresponse>')
|
||||
expected = '<aresponse><is_public>True</is_public>' \
|
||||
'<name><member><name1>test</name1></member></name>' \
|
||||
'</aresponse>'.encode('latin-1')
|
||||
actual = serializers.XMLResponseSerializer().to_xml(fixture)
|
||||
actual_xml_tree = etree.XML(actual)
|
||||
actual_xml_dict = self._recursive_dict(actual_xml_tree)
|
||||
@ -132,9 +131,11 @@ class XMLResponseSerializerTest(common.HeatTestCase):
|
||||
('Metadata', {"name2": "test2"}),
|
||||
]))
|
||||
])
|
||||
expected = six.b('<aresponse><is_public>True</is_public>'
|
||||
'<TemplateBody>{"name1": "test"}</TemplateBody>'
|
||||
'<Metadata>{"name2": "test2"}</Metadata></aresponse>')
|
||||
expected = '<aresponse>' \
|
||||
'<is_public>True</is_public>' \
|
||||
'<TemplateBody>{"name1": "test"}</TemplateBody>' \
|
||||
'<Metadata>{"name2": "test2"}</Metadata>' \
|
||||
'</aresponse>'.encode('latin-1')
|
||||
actual = serializers.XMLResponseSerializer().to_xml(fixture)
|
||||
actual_xml_tree = etree.XML(actual)
|
||||
actual_xml_dict = self._recursive_dict(actual_xml_tree)
|
||||
|
@ -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.engine import constraints
|
||||
@ -125,7 +124,7 @@ class SchemaTest(common.HeatTestCase):
|
||||
r = constraints.Modulo(step=2, offset=1)
|
||||
err = self.assertRaises(ValueError, r.validate, 4)
|
||||
self.assertIn('4 is not a multiple of 2 with an offset of 1',
|
||||
six.text_type(err))
|
||||
str(err))
|
||||
|
||||
self.assertRaises(ValueError, r.validate, 0)
|
||||
self.assertRaises(ValueError, r.validate, 2)
|
||||
@ -140,26 +139,26 @@ class SchemaTest(common.HeatTestCase):
|
||||
err = self.assertRaises(exception.InvalidSchemaError,
|
||||
constraints.Modulo, step=111, offset=111)
|
||||
self.assertIn('offset must be smaller (by absolute value) than step',
|
||||
six.text_type(err))
|
||||
str(err))
|
||||
|
||||
err = self.assertRaises(exception.InvalidSchemaError,
|
||||
constraints.Modulo, step=111, offset=112)
|
||||
self.assertIn('offset must be smaller (by absolute value) than step',
|
||||
six.text_type(err))
|
||||
str(err))
|
||||
|
||||
err = self.assertRaises(exception.InvalidSchemaError,
|
||||
constraints.Modulo, step=0, offset=1)
|
||||
self.assertIn('step cannot be 0', six.text_type(err))
|
||||
self.assertIn('step cannot be 0', str(err))
|
||||
|
||||
err = self.assertRaises(exception.InvalidSchemaError,
|
||||
constraints.Modulo, step=-2, offset=1)
|
||||
self.assertIn('step and offset must be both positive or both negative',
|
||||
six.text_type(err))
|
||||
str(err))
|
||||
|
||||
err = self.assertRaises(exception.InvalidSchemaError,
|
||||
constraints.Modulo, step=2, offset=-1)
|
||||
self.assertIn('step and offset must be both positive or both negative',
|
||||
six.text_type(err))
|
||||
str(err))
|
||||
|
||||
def test_schema_all(self):
|
||||
d = {
|
||||
@ -271,7 +270,7 @@ class SchemaTest(common.HeatTestCase):
|
||||
err = self.assertRaises(exception.InvalidSchemaError,
|
||||
schema.validate)
|
||||
self.assertIn('Range constraint invalid for String',
|
||||
six.text_type(err))
|
||||
str(err))
|
||||
|
||||
def test_length_invalid_type(self):
|
||||
schema = constraints.Schema('Integer',
|
||||
@ -279,7 +278,7 @@ class SchemaTest(common.HeatTestCase):
|
||||
err = self.assertRaises(exception.InvalidSchemaError,
|
||||
schema.validate)
|
||||
self.assertIn('Length constraint invalid for Integer',
|
||||
six.text_type(err))
|
||||
str(err))
|
||||
|
||||
def test_modulo_invalid_type(self):
|
||||
schema = constraints.Schema('String',
|
||||
@ -287,7 +286,7 @@ class SchemaTest(common.HeatTestCase):
|
||||
err = self.assertRaises(exception.InvalidSchemaError,
|
||||
schema.validate)
|
||||
self.assertIn('Modulo constraint invalid for String',
|
||||
six.text_type(err))
|
||||
str(err))
|
||||
|
||||
def test_allowed_pattern_invalid_type(self):
|
||||
schema = constraints.Schema(
|
||||
@ -297,7 +296,7 @@ class SchemaTest(common.HeatTestCase):
|
||||
err = self.assertRaises(exception.InvalidSchemaError,
|
||||
schema.validate)
|
||||
self.assertIn('AllowedPattern constraint invalid for Integer',
|
||||
six.text_type(err))
|
||||
str(err))
|
||||
|
||||
def test_range_vals_invalid_type(self):
|
||||
self.assertRaises(exception.InvalidSchemaError,
|
||||
@ -329,7 +328,7 @@ class SchemaTest(common.HeatTestCase):
|
||||
constraints=[constraints.Range(max=4)])
|
||||
err = self.assertRaises(exception.InvalidSchemaError, s.validate)
|
||||
self.assertIn('Range constraint invalid for String',
|
||||
six.text_type(err))
|
||||
str(err))
|
||||
|
||||
def test_schema_nested_validate_good(self):
|
||||
nested = constraints.Schema(constraints.Schema.STRING, 'A string',
|
||||
@ -347,7 +346,7 @@ class SchemaTest(common.HeatTestCase):
|
||||
schema={'Foo': nested})
|
||||
err = self.assertRaises(exception.InvalidSchemaError, s.validate)
|
||||
self.assertIn('Range constraint invalid for String',
|
||||
six.text_type(err))
|
||||
str(err))
|
||||
|
||||
def test_allowed_values_numeric_int(self):
|
||||
"""Test AllowedValues constraint for numeric integer values.
|
||||
@ -367,12 +366,12 @@ class SchemaTest(common.HeatTestCase):
|
||||
err = self.assertRaises(exception.StackValidationFailed,
|
||||
schema.validate_constraints, 3)
|
||||
self.assertEqual('3 is not an allowed value [1, 2, 4]',
|
||||
six.text_type(err))
|
||||
str(err))
|
||||
self.assertIsNone(schema.validate_constraints('1'))
|
||||
err = self.assertRaises(exception.StackValidationFailed,
|
||||
schema.validate_constraints, '3')
|
||||
self.assertEqual('"3" is not an allowed value [1, 2, 4]',
|
||||
six.text_type(err))
|
||||
str(err))
|
||||
|
||||
# Allowed values defined as integer strings
|
||||
schema = constraints.Schema(
|
||||
@ -384,12 +383,12 @@ class SchemaTest(common.HeatTestCase):
|
||||
err = self.assertRaises(exception.StackValidationFailed,
|
||||
schema.validate_constraints, 3)
|
||||
self.assertEqual('3 is not an allowed value ["1", "2", "4"]',
|
||||
six.text_type(err))
|
||||
str(err))
|
||||
self.assertIsNone(schema.validate_constraints('1'))
|
||||
err = self.assertRaises(exception.StackValidationFailed,
|
||||
schema.validate_constraints, '3')
|
||||
self.assertEqual('"3" is not an allowed value ["1", "2", "4"]',
|
||||
six.text_type(err))
|
||||
str(err))
|
||||
|
||||
def test_allowed_values_numeric_float(self):
|
||||
"""Test AllowedValues constraint for numeric floating point values.
|
||||
@ -409,12 +408,12 @@ class SchemaTest(common.HeatTestCase):
|
||||
err = self.assertRaises(exception.StackValidationFailed,
|
||||
schema.validate_constraints, 3.3)
|
||||
self.assertEqual('3.3 is not an allowed value [1.1, 2.2, 4.4]',
|
||||
six.text_type(err))
|
||||
str(err))
|
||||
self.assertIsNone(schema.validate_constraints('1.1'))
|
||||
err = self.assertRaises(exception.StackValidationFailed,
|
||||
schema.validate_constraints, '3.3')
|
||||
self.assertEqual('"3.3" is not an allowed value [1.1, 2.2, 4.4]',
|
||||
six.text_type(err))
|
||||
str(err))
|
||||
|
||||
# Allowed values defined as strings
|
||||
schema = constraints.Schema(
|
||||
@ -426,12 +425,12 @@ class SchemaTest(common.HeatTestCase):
|
||||
err = self.assertRaises(exception.StackValidationFailed,
|
||||
schema.validate_constraints, 3.3)
|
||||
self.assertEqual('3.3 is not an allowed value ["1.1", "2.2", "4.4"]',
|
||||
six.text_type(err))
|
||||
str(err))
|
||||
self.assertIsNone(schema.validate_constraints('1.1'))
|
||||
err = self.assertRaises(exception.StackValidationFailed,
|
||||
schema.validate_constraints, '3.3')
|
||||
self.assertEqual('"3.3" is not an allowed value ["1.1", "2.2", "4.4"]',
|
||||
six.text_type(err))
|
||||
str(err))
|
||||
|
||||
def test_to_schema_type_int(self):
|
||||
"""Test Schema.to_schema_type method for type Integer."""
|
||||
@ -444,14 +443,14 @@ class SchemaTest(common.HeatTestCase):
|
||||
# test invalid numeric values, i.e. floating point numbers
|
||||
err = self.assertRaises(ValueError, schema.to_schema_type, 1.5)
|
||||
self.assertEqual('Value "1.5" is invalid for data type "Integer".',
|
||||
six.text_type(err))
|
||||
str(err))
|
||||
err = self.assertRaises(ValueError, schema.to_schema_type, '1.5')
|
||||
self.assertEqual('Value "1.5" is invalid for data type "Integer".',
|
||||
six.text_type(err))
|
||||
str(err))
|
||||
# test invalid string values
|
||||
err = self.assertRaises(ValueError, schema.to_schema_type, 'foo')
|
||||
self.assertEqual('Value "foo" is invalid for data type "Integer".',
|
||||
six.text_type(err))
|
||||
str(err))
|
||||
|
||||
def test_to_schema_type_num(self):
|
||||
"""Test Schema.to_schema_type method for type Number."""
|
||||
@ -467,21 +466,21 @@ class SchemaTest(common.HeatTestCase):
|
||||
self.assertEqual(1.5, res)
|
||||
err = self.assertRaises(ValueError, schema.to_schema_type, 'foo')
|
||||
self.assertEqual('Value "foo" is invalid for data type "Number".',
|
||||
six.text_type(err))
|
||||
str(err))
|
||||
|
||||
def test_to_schema_type_string(self):
|
||||
"""Test Schema.to_schema_type method for type String."""
|
||||
schema = constraints.Schema('String')
|
||||
res = schema.to_schema_type('one')
|
||||
self.assertIsInstance(res, six.string_types)
|
||||
self.assertIsInstance(res, str)
|
||||
res = schema.to_schema_type('1')
|
||||
self.assertIsInstance(res, six.string_types)
|
||||
self.assertIsInstance(res, str)
|
||||
res = schema.to_schema_type(1)
|
||||
self.assertIsInstance(res, six.string_types)
|
||||
self.assertIsInstance(res, str)
|
||||
res = schema.to_schema_type(True)
|
||||
self.assertIsInstance(res, six.string_types)
|
||||
self.assertIsInstance(res, str)
|
||||
res = schema.to_schema_type(None)
|
||||
self.assertIsInstance(res, six.string_types)
|
||||
self.assertIsInstance(res, str)
|
||||
|
||||
def test_to_schema_type_boolean(self):
|
||||
"""Test Schema.to_schema_type method for type Boolean."""
|
||||
@ -501,7 +500,7 @@ class SchemaTest(common.HeatTestCase):
|
||||
|
||||
err = self.assertRaises(ValueError, schema.to_schema_type, 'foo')
|
||||
self.assertEqual('Value "foo" is invalid for data type "Boolean".',
|
||||
six.text_type(err))
|
||||
str(err))
|
||||
|
||||
def test_to_schema_type_map(self):
|
||||
"""Test Schema.to_schema_type method for type Map."""
|
||||
@ -533,11 +532,11 @@ class CustomConstraintTest(common.HeatTestCase):
|
||||
|
||||
constraint = constraints.CustomConstraint("zero", environment=self.env)
|
||||
self.assertEqual("Value must be of type zero",
|
||||
six.text_type(constraint))
|
||||
str(constraint))
|
||||
self.assertIsNone(constraint.validate(0))
|
||||
error = self.assertRaises(ValueError, constraint.validate, 1)
|
||||
self.assertEqual('"1" does not validate zero',
|
||||
six.text_type(error))
|
||||
str(error))
|
||||
|
||||
def test_custom_error(self):
|
||||
class ZeroConstraint(object):
|
||||
@ -552,7 +551,7 @@ class CustomConstraintTest(common.HeatTestCase):
|
||||
|
||||
constraint = constraints.CustomConstraint("zero", environment=self.env)
|
||||
error = self.assertRaises(ValueError, constraint.validate, 1)
|
||||
self.assertEqual("1 is not 0", six.text_type(error))
|
||||
self.assertEqual("1 is not 0", str(error))
|
||||
|
||||
def test_custom_message(self):
|
||||
class ZeroConstraint(object):
|
||||
@ -564,13 +563,13 @@ class CustomConstraintTest(common.HeatTestCase):
|
||||
self.env.register_constraint("zero", ZeroConstraint)
|
||||
|
||||
constraint = constraints.CustomConstraint("zero", environment=self.env)
|
||||
self.assertEqual("Only zero!", six.text_type(constraint))
|
||||
self.assertEqual("Only zero!", str(constraint))
|
||||
|
||||
def test_unknown_constraint(self):
|
||||
constraint = constraints.CustomConstraint("zero", environment=self.env)
|
||||
error = self.assertRaises(ValueError, constraint.validate, 1)
|
||||
self.assertEqual('"1" does not validate zero (constraint not found)',
|
||||
six.text_type(error))
|
||||
str(error))
|
||||
|
||||
def test_constraints(self):
|
||||
class ZeroConstraint(object):
|
||||
|
@ -12,7 +12,6 @@
|
||||
# under the License.
|
||||
|
||||
from oslo_config import cfg
|
||||
import six
|
||||
|
||||
from heat.common import config
|
||||
from heat.common import crypt
|
||||
@ -35,7 +34,7 @@ class CryptTest(common.HeatTestCase):
|
||||
config.startup_sanity_check)
|
||||
exp_msg = ('heat.conf misconfigured, auth_encryption_key '
|
||||
'must be 32 characters')
|
||||
self.assertIn(exp_msg, six.text_type(err))
|
||||
self.assertIn(exp_msg, str(err))
|
||||
|
||||
def _test_encrypt_decrypt_dict(self, encryption_key=None):
|
||||
data = {'p1': u'happy',
|
||||
@ -73,4 +72,4 @@ class CryptTest(common.HeatTestCase):
|
||||
'767c3ed056cbaa3b9dfedb8c6f825bf1')
|
||||
self.assertEqual('Can not decrypt data with the auth_encryption_key '
|
||||
'in heat config.',
|
||||
six.text_type(ex))
|
||||
str(ex))
|
||||
|
@ -17,7 +17,6 @@ import uuid
|
||||
|
||||
import mock
|
||||
from oslo_utils import timeutils
|
||||
import six
|
||||
|
||||
from heat.common import exception
|
||||
from heat.common import template_format
|
||||
@ -1187,7 +1186,7 @@ class TestExtractArgs(common.HeatTestCase):
|
||||
def test_timeout_extract_negative(self):
|
||||
p = {'timeout_mins': '-100'}
|
||||
error = self.assertRaises(ValueError, api.extract_args, p)
|
||||
self.assertIn('Invalid timeout value', six.text_type(error))
|
||||
self.assertIn('Invalid timeout value', str(error))
|
||||
|
||||
def test_timeout_extract_not_present(self):
|
||||
args = api.extract_args({})
|
||||
@ -1201,7 +1200,7 @@ class TestExtractArgs(common.HeatTestCase):
|
||||
def test_invalid_adopt_stack_data(self):
|
||||
params = {'adopt_stack_data': json.dumps("foo")}
|
||||
exc = self.assertRaises(ValueError, api.extract_args, params)
|
||||
self.assertIn('Invalid adopt data', six.text_type(exc))
|
||||
self.assertIn('Invalid adopt data', str(exc))
|
||||
|
||||
def test_adopt_stack_data_extract_not_present(self):
|
||||
args = api.extract_args({})
|
||||
@ -1249,12 +1248,12 @@ class TestExtractArgs(common.HeatTestCase):
|
||||
def test_tags_extract_not_map(self):
|
||||
p = {'tags': {"foo": "bar"}}
|
||||
exc = self.assertRaises(ValueError, api.extract_args, p)
|
||||
self.assertIn('Invalid tags, not a list: ', six.text_type(exc))
|
||||
self.assertIn('Invalid tags, not a list: ', str(exc))
|
||||
|
||||
def test_tags_extract_not_string(self):
|
||||
p = {'tags': ["tag1", 2]}
|
||||
exc = self.assertRaises(ValueError, api.extract_args, p)
|
||||
self.assertIn('Invalid tag, "2" is not a string', six.text_type(exc))
|
||||
self.assertIn('Invalid tag, "2" is not a string', str(exc))
|
||||
|
||||
def test_tags_extract_over_limit(self):
|
||||
p = {'tags': ["tag1", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
@ -1262,13 +1261,13 @@ class TestExtractArgs(common.HeatTestCase):
|
||||
exc = self.assertRaises(ValueError, api.extract_args, p)
|
||||
self.assertIn('Invalid tag, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
|
||||
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" is longer '
|
||||
'than 80 characters', six.text_type(exc))
|
||||
'than 80 characters', str(exc))
|
||||
|
||||
def test_tags_extract_comma(self):
|
||||
p = {'tags': ["tag1", 'tag2,']}
|
||||
exc = self.assertRaises(ValueError, api.extract_args, p)
|
||||
self.assertIn('Invalid tag, "tag2," contains a comma',
|
||||
six.text_type(exc))
|
||||
str(exc))
|
||||
|
||||
|
||||
class TranslateFilterTest(common.HeatTestCase):
|
||||
|
@ -17,7 +17,6 @@ import mock
|
||||
from oslo_config import cfg
|
||||
from oslo_messaging.rpc import dispatcher
|
||||
from oslo_serialization import jsonutils as json
|
||||
import six
|
||||
|
||||
from heat.common import context
|
||||
from heat.common import environment_util as env_util
|
||||
@ -852,7 +851,7 @@ class StackServiceTest(common.HeatTestCase):
|
||||
ret = self.assertRaises(exception.InvalidTemplateVersions,
|
||||
self.eng.list_template_versions, self.ctx)
|
||||
self.assertIn('A template version alias c.something was added',
|
||||
six.text_type(ret))
|
||||
str(ret))
|
||||
|
||||
@mock.patch('heat.engine.template._get_template_extension_manager')
|
||||
def test_list_template_functions(self, templ_mock):
|
||||
@ -920,7 +919,7 @@ class StackServiceTest(common.HeatTestCase):
|
||||
self.ctx,
|
||||
version)
|
||||
msg = "Template with version %s not found" % version
|
||||
self.assertEqual(msg, six.text_type(ex))
|
||||
self.assertEqual(msg, str(ex))
|
||||
|
||||
def test_stack_list_outputs(self):
|
||||
t = template_format.parse(tools.wp_template)
|
||||
@ -1041,7 +1040,7 @@ class StackServiceTest(common.HeatTestCase):
|
||||
self.ctx, mock.ANY, 'bunny')
|
||||
self.assertEqual(exception.NotFound, ex.exc_info[0])
|
||||
self.assertEqual('Specified output key bunny not found.',
|
||||
six.text_type(ex.exc_info[1]))
|
||||
str(ex.exc_info[1]))
|
||||
|
||||
def test_stack_show_output_error(self):
|
||||
t = template_format.parse(tools.wp_template)
|
||||
@ -1202,7 +1201,7 @@ class StackServiceTest(common.HeatTestCase):
|
||||
msg = (u'"Type" is not a valid keyword '
|
||||
'inside a resource definition')
|
||||
|
||||
self.assertEqual(msg, six.text_type(ex))
|
||||
self.assertEqual(msg, str(ex))
|
||||
|
||||
def test_validate_new_stack_checks_incorrect_sections(self):
|
||||
template = {'heat_template_version': '2013-05-23',
|
||||
@ -1214,7 +1213,7 @@ class StackServiceTest(common.HeatTestCase):
|
||||
self.ctx, 'test_existing_stack',
|
||||
parsed_template)
|
||||
msg = u'The template section is invalid: unknown_section'
|
||||
self.assertEqual(msg, six.text_type(ex))
|
||||
self.assertEqual(msg, str(ex))
|
||||
|
||||
def test_validate_new_stack_checks_resource_limit(self):
|
||||
cfg.CONF.set_override('max_resources_per_stack', 5)
|
||||
@ -1237,7 +1236,7 @@ class StackServiceTest(common.HeatTestCase):
|
||||
tmpl.validate.side_effect = AssertionError(expected_message)
|
||||
exc = self.assertRaises(AssertionError, self.eng._validate_new_stack,
|
||||
self.ctx, 'stack_name', tmpl)
|
||||
self.assertEqual(expected_message, six.text_type(exc))
|
||||
self.assertEqual(expected_message, str(exc))
|
||||
|
||||
@mock.patch('heat.engine.service.ThreadGroupManager',
|
||||
return_value=mock.Mock())
|
||||
|
@ -17,7 +17,6 @@ import sys
|
||||
import fixtures
|
||||
import mock
|
||||
from oslo_config import cfg
|
||||
import six
|
||||
|
||||
from heat.common import environment_format
|
||||
from heat.common import exception
|
||||
@ -209,7 +208,7 @@ def constraint_mapping():
|
||||
env = environment.Environment({})
|
||||
error = self.assertRaises(ValueError,
|
||||
resources._load_global_environment, env)
|
||||
self.assertEqual("oops", six.text_type(error))
|
||||
self.assertEqual("oops", str(error))
|
||||
|
||||
def test_constraints_registry_stevedore(self):
|
||||
env = environment.Environment({})
|
||||
@ -788,7 +787,7 @@ class ResourceRegistryTest(common.HeatTestCase):
|
||||
'\'post-delete\')')
|
||||
ex = self.assertRaises(exception.InvalidBreakPointHook,
|
||||
registry.load, {'resources': resources})
|
||||
self.assertEqual(msg, six.text_type(ex))
|
||||
self.assertEqual(msg, str(ex))
|
||||
|
||||
def test_list_type_validation_invalid_support_status(self):
|
||||
registry = environment.ResourceRegistry(None, {})
|
||||
@ -797,7 +796,7 @@ class ResourceRegistryTest(common.HeatTestCase):
|
||||
registry.get_types,
|
||||
support_status='junk')
|
||||
msg = ('Invalid support status and should be one of %s' %
|
||||
six.text_type(support.SUPPORT_STATUSES))
|
||||
str(support.SUPPORT_STATUSES))
|
||||
|
||||
self.assertIn(msg, ex.message)
|
||||
|
||||
|
@ -17,7 +17,6 @@
|
||||
|
||||
import fixtures
|
||||
import mock
|
||||
import six
|
||||
|
||||
from heat.common import exception
|
||||
from heat.common.i18n import _
|
||||
@ -39,7 +38,7 @@ class TestHeatException(common.HeatTestCase):
|
||||
def test_format_string_error_message(self):
|
||||
message = "This format %(message)s should work"
|
||||
err = exception.Error(message)
|
||||
self.assertEqual(message, six.text_type(err))
|
||||
self.assertEqual(message, str(err))
|
||||
|
||||
|
||||
class TestStackValidationFailed(common.HeatTestCase):
|
||||
@ -135,7 +134,7 @@ class TestStackValidationFailed(common.HeatTestCase):
|
||||
try:
|
||||
raise exception.StackValidationFailed(**self.kwargs)
|
||||
except exception.StackValidationFailed as ex:
|
||||
self.assertIn(self.expected, six.text_type(ex))
|
||||
self.assertIn(self.expected, str(ex))
|
||||
self.assertIn(self.called_error, ex.error)
|
||||
self.assertEqual(self.called_path, ex.path)
|
||||
self.assertEqual(self.called_msg, ex.error_message)
|
||||
|
@ -17,7 +17,6 @@ import re
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log
|
||||
from oslo_messaging._drivers import common as rpc_common
|
||||
import six
|
||||
import webob
|
||||
|
||||
import heat.api.middleware.fault as fault
|
||||
@ -123,7 +122,7 @@ class FaultMiddlewareTest(common.HeatTestCase):
|
||||
serialized, ["heat.common.exception"])
|
||||
wrapper = fault.FaultWrapper(None)
|
||||
msg = wrapper._error(remote_error)
|
||||
expected_message, expected_traceback = six.text_type(
|
||||
expected_message, expected_traceback = str(
|
||||
remote_error).split('\n', 1)
|
||||
expected = {'code': 404,
|
||||
'error': {'message': expected_message,
|
||||
@ -134,8 +133,7 @@ class FaultMiddlewareTest(common.HeatTestCase):
|
||||
self.assertEqual(expected, msg)
|
||||
|
||||
def remote_exception_helper(self, name, error):
|
||||
if six.PY3:
|
||||
error.args = ()
|
||||
error.args = ()
|
||||
exc_info = (type(error), error, None)
|
||||
|
||||
serialized = rpc_common.serialize_remote_exception(exc_info)
|
||||
@ -230,7 +228,7 @@ class FaultMiddlewareTest(common.HeatTestCase):
|
||||
|
||||
wrapper = fault.FaultWrapper(None)
|
||||
msg = wrapper._error(remote_error)
|
||||
expected_message, expected_traceback = six.text_type(
|
||||
expected_message, expected_traceback = str(
|
||||
remote_error).split('\n', 1)
|
||||
expected = {'code': 404,
|
||||
'error': {'message': expected_message,
|
||||
|
@ -14,7 +14,6 @@
|
||||
import copy
|
||||
import uuid
|
||||
|
||||
import six
|
||||
|
||||
from heat.common import exception
|
||||
from heat.common.i18n import _
|
||||
@ -77,7 +76,7 @@ class FunctionTest(common.HeatTestCase):
|
||||
func1 = TestFunction(None, 'foo', ['bar', 'baz'])
|
||||
expected = '%s %s' % ("<heat.tests.test_function.TestFunction",
|
||||
"{foo: ['bar', 'baz']} -> 'wibble'>")
|
||||
self.assertEqual(expected, six.text_type(func1))
|
||||
self.assertEqual(expected, str(func1))
|
||||
|
||||
def test_function_stack_reference_none(self):
|
||||
func1 = TestFunction(None, 'foo', ['bar', 'baz'])
|
||||
@ -87,7 +86,7 @@ class FunctionTest(common.HeatTestCase):
|
||||
func1 = TestFunctionKeyError(None, 'foo', ['bar', 'baz'])
|
||||
expected = '%s %s' % ("<heat.tests.test_function.TestFunctionKeyError",
|
||||
"{foo: ['bar', 'baz']} -> ???>")
|
||||
self.assertEqual(expected, six.text_type(func1))
|
||||
self.assertEqual(expected, str(func1))
|
||||
|
||||
def test_function_eq_exception_key_error(self):
|
||||
func1 = TestFunctionKeyError(None, 'foo', ['bar', 'baz'])
|
||||
@ -106,7 +105,7 @@ class FunctionTest(common.HeatTestCase):
|
||||
expected = '%s %s' % (
|
||||
"<heat.tests.test_function.TestFunctionValueError",
|
||||
"{foo: ['bar', 'baz']} -> ???>")
|
||||
self.assertEqual(expected, six.text_type(func1))
|
||||
self.assertEqual(expected, str(func1))
|
||||
|
||||
def test_function_eq_exception_value_error(self):
|
||||
func1 = TestFunctionValueError(None, 'foo', ['bar', 'baz'])
|
||||
@ -126,7 +125,7 @@ class FunctionTest(common.HeatTestCase):
|
||||
"<heat.tests.test_function.TestFunctionResult",
|
||||
"{foo: ['bar', 'baz']}",
|
||||
"{'foo': ['bar', 'baz']}>")
|
||||
self.assertEqual(expected, six.text_type(func1))
|
||||
self.assertEqual(expected, str(func1))
|
||||
|
||||
def test_copy(self):
|
||||
func = TestFunction(None, 'foo', ['bar', 'baz'])
|
||||
@ -278,7 +277,7 @@ class ValidateGetAttTest(common.HeatTestCase):
|
||||
ex = self.assertRaises(exception.InvalidTemplateReference,
|
||||
func.validate)
|
||||
self.assertEqual('The specified reference "test_rsrc" (in unknown) '
|
||||
'is incorrect.', six.text_type(ex))
|
||||
'is incorrect.', str(ex))
|
||||
|
||||
def test_resource_no_attribute_with_default_fn_get_att(self):
|
||||
res_defn = rsrc_defn.ResourceDefinition('test_rsrc',
|
||||
@ -294,7 +293,7 @@ class ValidateGetAttTest(common.HeatTestCase):
|
||||
ex = self.assertRaises(exception.InvalidTemplateAttribute,
|
||||
func.validate)
|
||||
self.assertEqual('The Referenced Attribute (test_rsrc Bar) '
|
||||
'is incorrect.', six.text_type(ex))
|
||||
'is incorrect.', str(ex))
|
||||
|
||||
def test_resource_no_attribute_with_overwritten_fn_get_att(self):
|
||||
res_defn = rsrc_defn.ResourceDefinition('test_rsrc',
|
||||
@ -315,4 +314,4 @@ class ValidateGetAttTest(common.HeatTestCase):
|
||||
self.stack.defn, 'Fn::GetAtt', [self.rsrc.name])
|
||||
self.assertEqual('Arguments to "Fn::GetAtt" must be '
|
||||
'of the form [resource_name, attribute]',
|
||||
six.text_type(ex))
|
||||
str(ex))
|
||||
|
Loading…
Reference in New Issue
Block a user