workflows: close pdf file after reading (#51881)
This commit is contained in:
parent
08780d7935
commit
74c9e66d6a
|
@ -3404,10 +3404,10 @@ def test_geolocate_overwrite(pub):
|
|||
|
||||
@pytest.mark.skipif(transform_to_pdf is None, reason='libreoffice not found')
|
||||
def test_transform_to_pdf():
|
||||
instream = open(os.path.join(os.path.dirname(__file__), 'template.odt'), 'rb')
|
||||
outstream = transform_to_pdf(instream)
|
||||
assert outstream is not False
|
||||
assert outstream.read(10).startswith(b'%PDF-')
|
||||
with open(os.path.join(os.path.dirname(__file__), 'template.odt'), 'rb') as instream:
|
||||
outstream = transform_to_pdf(instream)
|
||||
assert outstream is not False
|
||||
assert outstream.read(10).startswith(b'%PDF-')
|
||||
|
||||
|
||||
def test_export_to_model_image(pub):
|
||||
|
|
|
@ -119,7 +119,9 @@ try:
|
|||
'libreoffice failed to produce pdf (stdout: %r, stderr: %r)'
|
||||
% (lo_output.stdout, lo_output.stderr)
|
||||
)
|
||||
return open(infile.name + '.pdf', 'rb')
|
||||
with open(infile.name + '.pdf', 'rb') as fd:
|
||||
pdf_stream = io.BytesIO(fd.read())
|
||||
return pdf_stream
|
||||
except subprocess.CalledProcessError:
|
||||
raise Exception('libreoffice is failing')
|
||||
finally:
|
||||
|
|
Loading…
Reference in New Issue