Replace str with six.text_type in tests

Replace str with six.text_type in necessary places, so that lazy
translation can be enabled in subsequent patches.

Change-Id: I40732ec7e9f53b3cb487880965797253452f95cd
This commit is contained in:
Liang Chen 2014-02-23 15:36:20 +08:00
parent a2d04996ae
commit 880e7898aa
4 changed files with 17 additions and 9 deletions

View File

@ -16,6 +16,7 @@ import json
import uuid
import mock
import six
from heat.common.identifier import EventIdentifier
from heat.common import template_format
@ -54,7 +55,7 @@ class EngineApiTest(HeatTestCase):
def test_timeout_extract_negative(self):
p = {'timeout_mins': '-100'}
error = self.assertRaises(ValueError, api.extract_args, p)
self.assertIn('Invalid timeout value', str(error))
self.assertIn('Invalid timeout value', six.text_type(error))
def test_timeout_extract_not_present(self):
args = api.extract_args({})
@ -70,7 +71,7 @@ class EngineApiTest(HeatTestCase):
error = self.assertRaises(ValueError, api.extract_args, p)
self.assertEqual(
'Unexpected adopt data "foo". Adopt data must be a dict.',
str(error))
six.text_type(error))
def test_adopt_stack_data_extract_not_present(self):
args = api.extract_args({})

View File

@ -11,6 +11,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import six
from heat.common import exception as heat_exc
from heat.openstack.common.rpc import common as rpc_common
from heat.tests.common import HeatTestCase
@ -80,7 +82,8 @@ class FaultMiddlewareTest(HeatTestCase):
serialized)
wrapper = fault.FaultWrapper(None)
msg = wrapper._error(remote_error)
expected_message, expected_traceback = str(remote_error).split('\n', 1)
expected_message, expected_traceback = six.text_type(remote_error).\
split('\n', 1)
expected = {'code': 404,
'error': {'message': expected_message,
'traceback': expected_traceback,
@ -132,7 +135,8 @@ class FaultMiddlewareTest(HeatTestCase):
wrapper = fault.FaultWrapper(None)
msg = wrapper._error(remote_error)
expected_message, expected_traceback = str(remote_error).split('\n', 1)
expected_message, expected_traceback = six.text_type(remote_error).\
split('\n', 1)
expected = {'code': 404,
'error': {'message': expected_message,
'traceback': expected_traceback,

View File

@ -11,6 +11,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import six
from heat.common import exception
from heat.common import identifier
from heat.common import template_format
@ -412,7 +414,7 @@ class HOTemplateTest(HeatTestCase):
snippet, tmpl, stack)
self.assertEqual(
'Argument to "get_file" must be a string',
str(notStrErr))
six.text_type(notStrErr))
def test_get_file_missing_files(self):
"""Test get_file function with no matching key in files section."""
@ -429,7 +431,7 @@ class HOTemplateTest(HeatTestCase):
self.assertEqual(
('No content found in the "files" section for '
'get_file path: file:///tmp/foo.yaml'),
str(missingErr))
six.text_type(missingErr))
def test_get_file_nested_does_not_resolve(self):
"""Test get_file function does not resolve nested calls."""
@ -465,11 +467,11 @@ class HOTemplateTest(HeatTestCase):
#Hot template test
keyError = self.assertRaises(KeyError, tmpl.__getitem__, 'parameters')
self.assertIn(err_str, str(keyError))
self.assertIn(err_str, six.text_type(keyError))
#CFN template test
keyError = self.assertRaises(KeyError, tmpl.__getitem__, 'Parameters')
self.assertIn(err_str, str(keyError))
self.assertIn(err_str, six.text_type(keyError))
def test_parameters_section_not_iterable(self):
"""

View File

@ -16,6 +16,7 @@ import os
import mock
import testtools
import yaml
import six
from heat.common import config
from heat.common import exception
@ -83,7 +84,7 @@ class YamlMinimalTest(HeatTestCase):
parse_ex = self.assertRaises(ValueError,
template_format.parse,
tmpl_str)
self.assertIn(msg_str, str(parse_ex))
self.assertIn(msg_str, six.text_type(parse_ex))
def test_long_yaml(self):
template = {'HeatTemplateFormatVersion': '2012-12-12'}