From fcba3fa9c811935b7a23c5f8e0b951c6c7ac2124 Mon Sep 17 00:00:00 2001 From: Ethan Lynn Date: Fri, 19 Sep 2014 14:56:50 +0800 Subject: [PATCH] Use six to translate exception message in tests Use six to translate exception message in tests Change-Id: I129de2f350ef31c6a8ef10355ada20d7789049a9 --- heat/tests/test_function.py | 4 ++-- heat/tests/test_instance.py | 6 +++--- heat/tests/test_neutron.py | 4 ++-- heat/tests/test_parser.py | 4 ++-- heat/tests/test_resource.py | 2 +- heat/tests/test_server.py | 4 ++-- heat/tests/test_sqlalchemy_api.py | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/heat/tests/test_function.py b/heat/tests/test_function.py index 3793e6126..72627a246 100644 --- a/heat/tests/test_function.py +++ b/heat/tests/test_function.py @@ -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', diff --git a/heat/tests/test_instance.py b/heat/tests/test_instance.py index 500daa6bf..49a38ad6f 100644 --- a/heat/tests/test_instance.py +++ b/heat/tests/test_instance.py @@ -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() diff --git a/heat/tests/test_neutron.py b/heat/tests/test_neutron.py index 53235c69a..819509ded 100644 --- a/heat/tests/test_neutron.py +++ b/heat/tests/test_neutron.py @@ -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): diff --git a/heat/tests/test_parser.py b/heat/tests/test_parser.py index 4bf99ab5d..e6bbf43a3 100644 --- a/heat/tests/test_parser.py +++ b/heat/tests/test_parser.py @@ -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)) diff --git a/heat/tests/test_resource.py b/heat/tests/test_resource.py index d194711a6..27041ab2c 100644 --- a/heat/tests/test_resource.py +++ b/heat/tests/test_resource.py @@ -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() diff --git a/heat/tests/test_server.py b/heat/tests/test_server.py index 5a4ece117..76681cc44 100644 --- a/heat/tests/test_server.py +++ b/heat/tests/test_server.py @@ -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() diff --git a/heat/tests/test_sqlalchemy_api.py b/heat/tests/test_sqlalchemy_api.py index 54497adaa..c83e76578 100644 --- a/heat/tests/test_sqlalchemy_api.py +++ b/heat/tests/test_sqlalchemy_api.py @@ -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