From 41000ecae3f59c8e766b83b4dfc2e67467eef00f Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Fri, 19 Jan 2018 20:16:51 +0000 Subject: Fix tests on Python 2.6 --- tests/docx/docx_tests.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/docx/docx_tests.py b/tests/docx/docx_tests.py index fd53d4f..9f2af01 100644 --- a/tests/docx/docx_tests.py +++ b/tests/docx/docx_tests.py @@ -65,9 +65,12 @@ def when_document_xml_is_not_present_then_document_is_found_using_file_relations def _create_zip(files): fileobj = io.BytesIO() - with zipfile.ZipFile(fileobj, "w") as zip_file: + zip_file = zipfile.ZipFile(fileobj, "w") + try: for name, contents in files.items(): zip_file.writestr(name, contents) + finally: + zip_file.close() fileobj.seek(0) return fileobj -- cgit v1.2.3