Skip to content

Commit 44d2f83

Browse files
author
Steve Canny
committed
add ZipPkgWriter.close()
1 parent 64932b0 commit 44d2f83

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

opc/phys_pkg.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,10 @@ class ZipPkgWriter(object):
7979
def __init__(self, pkg_file):
8080
super(ZipPkgWriter, self).__init__()
8181
self._zipf = ZipFile(pkg_file, 'w', compression=ZIP_DEFLATED)
82+
83+
def close(self):
84+
"""
85+
Close the zip archive, flushing any pending physical writes and
86+
releasing any resources it's using.
87+
"""
88+
self._zipf.close()

tests/test_phys_pkg.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,12 @@ def it_opens_pkg_file_zip_on_construction(self, ZipFile_):
115115
ZipPkgWriter(pkg_file)
116116
ZipFile_.assert_called_once_with(pkg_file, 'w',
117117
compression=ZIP_DEFLATED)
118+
119+
def it_can_be_closed(self, ZipFile_):
120+
# mockery ----------------------
121+
zipf = ZipFile_.return_value
122+
zip_pkg_writer = ZipPkgWriter(None)
123+
# exercise ---------------------
124+
zip_pkg_writer.close()
125+
# verify -----------------------
126+
zipf.close.assert_called_once_with()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy