From 3e9f3f74242a71aaf3e9967e987e06f19204d011 Mon Sep 17 00:00:00 2001 From: Artur Barseghyan Date: Wed, 11 Jan 2023 21:50:56 +0100 Subject: [PATCH] Clean up --- src/faker_file/providers/docx_file.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/faker_file/providers/docx_file.py b/src/faker_file/providers/docx_file.py index 2ac6d180..c8c8ddf8 100644 --- a/src/faker_file/providers/docx_file.py +++ b/src/faker_file/providers/docx_file.py @@ -86,13 +86,13 @@ def docx_file( content=content, ) - stream = BytesIO() - document = Document() - document.add_paragraph(content) - document.save(stream) - stream.seek(0) + with BytesIO() as _fake_file: + document = Document() + document.add_paragraph(content) + document.save(_fake_file) + _fake_file.seek(0) - storage.write_bytes(filename, stream.read()) + storage.write_bytes(filename, _fake_file.read()) # Generic file_name = StringValue(storage.relpath(filename))