Merge "Open local image files with "rb" mode" into stable/wallaby
This commit is contained in:
commit
e9423e9705
|
@ -365,7 +365,7 @@ class GlanceImageService(object):
|
||||||
# a system call to cp could have significant performance
|
# a system call to cp could have significant performance
|
||||||
# advantages, however we do not have the path to files at
|
# advantages, however we do not have the path to files at
|
||||||
# this point in the abstraction.
|
# this point in the abstraction.
|
||||||
with open(parsed_url.path, "r") as f:
|
with open(parsed_url.path, "rb") as f:
|
||||||
shutil.copyfileobj(f, data)
|
shutil.copyfileobj(f, data)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
@ -830,6 +830,7 @@ class TestGlanceImageService(test.TestCase):
|
||||||
self.flags(allowed_direct_url_schemes=['file'])
|
self.flags(allowed_direct_url_schemes=['file'])
|
||||||
self.service.download(self.context, image_id, writer)
|
self.service.download(self.context, image_id, writer)
|
||||||
mock_copyfileobj.assert_called_once_with(mock.ANY, writer)
|
mock_copyfileobj.assert_called_once_with(mock.ANY, writer)
|
||||||
|
mock_open.assert_called_once_with('/tmp/test', 'rb')
|
||||||
|
|
||||||
@mock.patch('six.moves.builtins.open')
|
@mock.patch('six.moves.builtins.open')
|
||||||
@mock.patch('shutil.copyfileobj')
|
@mock.patch('shutil.copyfileobj')
|
||||||
|
|
Loading…
Reference in New Issue