Use six to translate exception message in tests

Use six to translate exception message in tests

Change-Id: I129de2f350ef31c6a8ef10355ada20d7789049a9
This commit is contained in:
Ethan Lynn 2014-09-19 14:56:50 +08:00
parent 442e79b559
commit fcba3fa9c8
7 changed files with 14 additions and 14 deletions

View File

@ -195,7 +195,7 @@ class ValidateGetAttTest(HeatTestCase):
ex = self.assertRaises(exception.InvalidTemplateReference,
func.validate)
self.assertEqual('The specified reference "test_rsrc" (in unknown) '
'is incorrect.', str(ex))
'is incorrect.', six.text_type(ex))
def test_resource_no_attribute_with_default_fn_get_att(self):
func = functions.GetAtt(self.stack, 'Fn::GetAtt',
@ -203,7 +203,7 @@ class ValidateGetAttTest(HeatTestCase):
ex = self.assertRaises(exception.InvalidTemplateAttribute,
func.validate)
self.assertEqual('The Referenced Attribute (test_rsrc Bar) '
'is incorrect.', str(ex))
'is incorrect.', six.text_type(ex))
def test_resource_no_attribute_with_overwritten_fn_get_att(self):
res_defn = rsrc_defn.ResourceDefinition('test_rsrc',

View File

@ -433,7 +433,7 @@ class InstancesTest(HeatTestCase):
instance._check_active = mock.Mock(return_value=False)
exc = self.assertRaises(exception.Error, instance.handle_check)
self.assertIn('foo', str(exc))
self.assertIn('foo', six.text_type(exc))
class FakeVolumeAttach(object):
def started(self):
@ -450,7 +450,7 @@ class InstancesTest(HeatTestCase):
(return_server, self.FakeVolumeAttach()))
self.assertEqual(
'Instance is not active - Unknown status BOGUS',
str(e))
six.text_type(e))
def test_instance_create_error_status(self):
return_server = self.fc.servers.list()[1]
@ -471,7 +471,7 @@ class InstancesTest(HeatTestCase):
(return_server, self.FakeVolumeAttach()))
self.assertEqual(
'Went to status ERROR due to "Message: NoValidHost, Code: 500"',
str(e))
six.text_type(e))
self.m.VerifyAll()

View File

@ -508,13 +508,13 @@ class NeutronTest(HeatTestCase):
})
self.assertEqual(
'Went to status ERROR due to "Unknown"',
str(e))
six.text_type(e))
e = self.assertRaises(resource.ResourceUnknownStatus, qr.is_built, {
'status': 'FROBULATING'
})
self.assertEqual(
'Resource is not built - Unknown status FROBULATING',
str(e))
six.text_type(e))
def test_resolve_attribute(self):
class SomeNeutronResource(qr):

View File

@ -4192,7 +4192,7 @@ class StackTest(HeatTestCase):
self.assertEqual('Output validation error: The Referenced Attribute '
'(AResource Bar) is incorrect.',
str(ex))
six.text_type(ex))
def test_incorrect_outputs_hot_get_attr(self):
tmpl = {'heat_template_version': '2013-05-23',
@ -4212,4 +4212,4 @@ class StackTest(HeatTestCase):
self.assertEqual('Output validation error: The Referenced Attribute '
'(AResource Bar) is incorrect.',
str(ex))
six.text_type(ex))

View File

@ -573,7 +573,7 @@ class ResourceTest(HeatTestCase):
estr = ('ResourceInError: Went to status ERROR due to "just because"')
create = scheduler.TaskRunner(res.create)
err = self.assertRaises(exception.ResourceFailure, create)
self.assertEqual(estr, str(err))
self.assertEqual(estr, six.text_type(err))
self.assertEqual((res.CREATE, res.FAILED), res.state)
self.m.VerifyAll()

View File

@ -410,7 +410,7 @@ class ServersTest(HeatTestCase):
return_server)
self.assertEqual(
'Server is not active - Unknown status BOGUS',
str(e))
six.text_type(e))
def test_server_create_error_status(self):
return_server = self.fc.servers.list()[1]
@ -431,7 +431,7 @@ class ServersTest(HeatTestCase):
return_server)
self.assertEqual(
'Went to status ERROR due to "Message: NoValidHost, Code: 500"',
str(e))
six.text_type(e))
self.m.VerifyAll()

View File

@ -844,12 +844,12 @@ class SqlAlchemyTest(HeatTestCase):
db_api.software_config_get,
self.ctx,
config_id)
self.assertIn(config_id, str(err))
self.assertIn(config_id, six.text_type(err))
err = self.assertRaises(
exception.NotFound, db_api.software_config_delete,
self.ctx, config_id)
self.assertIn(config_id, str(err))
self.assertIn(config_id, six.text_type(err))
def _deployment_values(self):
tenant_id = self.ctx.tenant_id