Merge "Replace str with six.text_type in tests"

This commit is contained in:
Jenkins 2014-04-14 03:47:03 +00:00 committed by Gerrit Code Review
commit 4e5a19d4f6
4 changed files with 17 additions and 9 deletions

View File

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

View File

@ -11,6 +11,8 @@
# 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 as heat_exc from heat.common import exception as heat_exc
from heat.openstack.common.rpc import common as rpc_common from heat.openstack.common.rpc import common as rpc_common
from heat.tests.common import HeatTestCase from heat.tests.common import HeatTestCase
@ -80,7 +82,8 @@ class FaultMiddlewareTest(HeatTestCase):
serialized) serialized)
wrapper = fault.FaultWrapper(None) wrapper = fault.FaultWrapper(None)
msg = wrapper._error(remote_error) 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, expected = {'code': 404,
'error': {'message': expected_message, 'error': {'message': expected_message,
'traceback': expected_traceback, 'traceback': expected_traceback,
@ -132,7 +135,8 @@ class FaultMiddlewareTest(HeatTestCase):
wrapper = fault.FaultWrapper(None) wrapper = fault.FaultWrapper(None)
msg = wrapper._error(remote_error) 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, expected = {'code': 404,
'error': {'message': expected_message, 'error': {'message': expected_message,
'traceback': expected_traceback, 'traceback': expected_traceback,

View File

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

View File

@ -16,6 +16,7 @@ import os
import mock import mock
import testtools import testtools
import yaml import yaml
import six
from heat.common import config from heat.common import config
from heat.common import exception from heat.common import exception
@ -83,7 +84,7 @@ class YamlMinimalTest(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, str(parse_ex)) self.assertIn(msg_str, six.text_type(parse_ex))
def test_long_yaml(self): def test_long_yaml(self):
template = {'HeatTemplateFormatVersion': '2012-12-12'} template = {'HeatTemplateFormatVersion': '2012-12-12'}