From: Steven Hardy Date: Wed, 13 Mar 2013 18:03:34 +0000 (+0000) Subject: heat engine : fix exception syntax issue X-Git-Tag: 2014.1~762^2 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=834b87a258a162ff8462de98b54a8036bf592d87;p=openstack-build%2Fheat-build.git heat engine : fix exception syntax issue Fix exception clause to use a tuple or the two types of exception are not correctly caught. fixes bug 1154708 Change-Id: Ia742c92dc189d03f8034ca864334526f1234dde3 --- diff --git a/heat/engine/service.py b/heat/engine/service.py index d84ca175..b56cf83a 100644 --- a/heat/engine/service.py +++ b/heat/engine/service.py @@ -377,7 +377,7 @@ class EngineService(service.Service): # are deployed as ec2 keypairs try: ec2_creds = json.loads(cnxt.aws_creds).get('ec2Credentials') - except TypeError, AttributeError: + except (TypeError, AttributeError): ec2_creds = None if ec2_creds: diff --git a/heat/tests/test_engine_service.py b/heat/tests/test_engine_service.py index 81880972..e5ed9679 100644 --- a/heat/tests/test_engine_service.py +++ b/heat/tests/test_engine_service.py @@ -15,6 +15,7 @@ import os import unittest +import json import mox from nose.plugins.attrib import attr @@ -644,6 +645,20 @@ class stackServiceTest(unittest.TestCase): self.stack_identity, 'foo')) + def test_stack_authorize_stack_user_attribute_error(self): + self.m.StubOutWithMock(json, 'loads') + json.loads(mox.IgnoreArg()).AndRaise(AttributeError) + self.assertFalse(self.man._authorize_stack_user(self.ctx, + self.stack_identity, + 'foo')) + + def test_stack_authorize_stack_user_type_error(self): + self.m.StubOutWithMock(json, 'loads') + json.loads(mox.IgnoreArg()).AndRaise(TypeError) + self.assertFalse(self.man._authorize_stack_user(self.ctx, + self.stack_identity, + 'foo')) + def test_stack_resources_describe(self): resources = self.man.describe_stack_resources(self.ctx, self.stack_identity,