Merge "Do not use "file" builtin, but "open" instead"
This commit is contained in:
commit
5d6012ad42
|
@ -290,7 +290,7 @@ class ApiSampleTestBase(integrated_helpers._IntegratedTestBase):
|
|||
self._write_sample(name, response_data)
|
||||
sample_data = response_data
|
||||
else:
|
||||
with file(self._get_sample(name,
|
||||
with open(self._get_sample(name,
|
||||
self.microversion)) as sample:
|
||||
sample_data = sample.read()
|
||||
if update_links:
|
||||
|
|
|
@ -1200,7 +1200,7 @@ class TestObjectVersions(test.NoDBTestCase):
|
|||
fingerprints = checker.get_hashes(extra_data_func=get_extra_data)
|
||||
|
||||
if os.getenv('GENERATE_HASHES'):
|
||||
file('object_hashes.txt', 'w').write(
|
||||
open('object_hashes.txt', 'w').write(
|
||||
pprint.pformat(fingerprints))
|
||||
raise test.TestingException(
|
||||
'Generated hashes in object_hashes.txt')
|
||||
|
|
|
@ -208,8 +208,8 @@ class RawTGZTestCase(test.NoDBTestCase):
|
|||
def test_stream_to_without_size_retrieved(self):
|
||||
source_tar = self.mox.CreateMock(tarfile.TarFile)
|
||||
first_tarinfo = self.mox.CreateMock(tarfile.TarInfo)
|
||||
target_file = self.mox.CreateMock(file)
|
||||
source_file = self.mox.CreateMock(file)
|
||||
target_file = self.mox.CreateMock(open)
|
||||
source_file = self.mox.CreateMock(open)
|
||||
|
||||
image = utils.RawTGZImage(None)
|
||||
image._image_service_and_image_id = ('service', 'id')
|
||||
|
@ -230,8 +230,8 @@ class RawTGZTestCase(test.NoDBTestCase):
|
|||
def test_stream_to_with_size_retrieved(self):
|
||||
source_tar = self.mox.CreateMock(tarfile.TarFile)
|
||||
first_tarinfo = self.mox.CreateMock(tarfile.TarInfo)
|
||||
target_file = self.mox.CreateMock(file)
|
||||
source_file = self.mox.CreateMock(file)
|
||||
target_file = self.mox.CreateMock(open)
|
||||
source_file = self.mox.CreateMock(open)
|
||||
first_tarinfo.size = 124
|
||||
|
||||
image = utils.RawTGZImage(None)
|
||||
|
|
|
@ -17,6 +17,7 @@ import contextlib
|
|||
import tarfile
|
||||
|
||||
import eventlet
|
||||
import six
|
||||
|
||||
from nova.image import glance
|
||||
from nova import test
|
||||
|
@ -147,14 +148,14 @@ class TestTarGzProducer(test.NoDBTestCase):
|
|||
self.assertEqual('writefile', producer.output)
|
||||
|
||||
def test_start(self):
|
||||
outf = self.mox.CreateMock(file)
|
||||
outf = six.StringIO()
|
||||
producer = vdi_through_dev.TarGzProducer('fpath', outf,
|
||||
'100', 'fname')
|
||||
|
||||
tfile = self.mox.CreateMock(tarfile.TarFile)
|
||||
tinfo = self.mox.CreateMock(tarfile.TarInfo)
|
||||
|
||||
inf = self.mox.CreateMock(file)
|
||||
inf = self.mox.CreateMock(open)
|
||||
|
||||
self.mox.StubOutWithMock(vdi_through_dev, 'tarfile')
|
||||
self.mox.StubOutWithMock(producer, '_open_file')
|
||||
|
|
|
@ -304,13 +304,13 @@ def load_file(path):
|
|||
def file_open(*args, **kwargs):
|
||||
"""Open file
|
||||
|
||||
see built-in file() documentation for more details
|
||||
see built-in open() documentation for more details
|
||||
|
||||
Note: The reason this is kept in a separate module is to easily
|
||||
be able to provide a stub module that doesn't alter system
|
||||
state at all (for unit tests)
|
||||
"""
|
||||
return file(*args, **kwargs)
|
||||
return open(*args, **kwargs)
|
||||
|
||||
|
||||
def file_delete(path):
|
||||
|
|
|
@ -2211,7 +2211,7 @@ def vdi_attached_here(session, vdi_ref, read_only=False):
|
|||
|
||||
|
||||
def _get_sys_hypervisor_uuid():
|
||||
with file('/sys/hypervisor/uuid') as f:
|
||||
with open('/sys/hypervisor/uuid') as f:
|
||||
return f.readline().strip()
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue