Merge "Should not raise Exception before connection close"
This commit is contained in:
commit
961869e061
@ -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):
|
||||
|
@ -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."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user