Merge "Should not raise Exception before connection close"

This commit is contained in:
Jenkins 2016-03-11 17:45:07 +00:00 committed by Gerrit Code Review
commit 961869e061
2 changed files with 12 additions and 1 deletions

View File

@ -617,7 +617,8 @@ class VmdkReadHandle(FileHandle):
self._url,
exc_info=True)
raise
super(VmdkReadHandle, self).close()
finally:
super(VmdkReadHandle, self).close()
LOG.debug("Closed VMDK read handle for %s.", self._url)
def __str__(self):

View File

@ -341,6 +341,16 @@ class VmdkReadHandleTest(base.TestCase):
handle.close()
self.assertEqual(2, session.invoke_api.call_count)
def test_close_with_error(self):
session = self._create_mock_session()
handle = rw_handles.VmdkReadHandle(session, '10.1.2.3', 443,
'vm-1', '[ds] disk1.vmdk',
100)
session.invoke_api.side_effect = exceptions.VimException(None)
self.assertRaises(exceptions.VimException, handle.close)
self._resp.close.assert_called_once_with()
class ImageReadHandleTest(base.TestCase):
"""Tests for ImageReadHandle."""