Fix py34 issues

The Nova project now has clean tox py34 runs with a limited set
of the UT.  This change set fixes two existing py34 issues
and allows py34 to run cleanly. The fixed issues are:

 - Use the 'builtins' module instead of __builtin__.
 - Don't log exceptions before they are raised.

Change-Id: Ib66e36c54353833b8ec35ff6f34b3cd81d609334
This commit is contained in:
Kyle L. Henderson 2015-07-29 20:48:06 -05:00 committed by Eric Fried
parent d73c7e60e4
commit e15ae76064
2 changed files with 7 additions and 2 deletions

View File

@ -15,16 +15,22 @@
# under the License.
import mock
import six
from nova import test
from nova_powervm.virt.powervm import image
if six.PY2:
_BUILTIN = '__builtin__'
else:
_BUILTIN = 'builtins'
class TestImage(test.TestCase):
@mock.patch('nova.utils.temporary_chown')
@mock.patch('__builtin__.open')
@mock.patch(_BUILTIN + '.open')
@mock.patch('nova.image.api.API')
def test_stream_blockdev_to_glance(self, mock_api, mock_open, mock_chown):
mock_open.return_value.__enter__.return_value = 'mock_stream'

View File

@ -267,7 +267,6 @@ class VMBuilder(object):
# Check if this is a valid attribute
if key not in self._ATTRS_MAP.keys():
exc = exception.InvalidAttribute(attr=key)
LOG.exception(exc)
raise exc
return True