[Python-checkins] cpython (merge 3.2 -> default): Issue #9239: add tests for modifying zipfile comments in append mode.
antoine.pitrou
python-checkins at python.org
Sat Jun 30 17:34:20 CEST 2012
http://hg.python.org/cpython/rev/b299b4279e13
changeset: 77874:b299b4279e13
parent: 77871:b0605b34b2de
parent: 77873:e13c9f99fbae
user: Antoine Pitrou <solipsis at pitrou.net>
date: Sat Jun 30 17:32:41 2012 +0200
summary:
Issue #9239: add tests for modifying zipfile comments in append mode.
files:
Lib/test/test_zipfile.py | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/Lib/test/test_zipfile.py b/Lib/test/test_zipfile.py
--- a/Lib/test/test_zipfile.py
+++ b/Lib/test/test_zipfile.py
@@ -1134,6 +1134,24 @@
with zipfile.ZipFile(TESTFN, mode="r") as zipfr:
self.assertEqual(zipfr.comment, comment2)
+ # check that comments are correctly modified in append mode
+ with zipfile.ZipFile(TESTFN,mode="w") as zipf:
+ zipf.comment = b"original comment"
+ zipf.writestr("foo.txt", "O, for a Muse of Fire!")
+ with zipfile.ZipFile(TESTFN,mode="a") as zipf:
+ zipf.comment = b"an updated comment"
+ with zipfile.ZipFile(TESTFN,mode="r") as zipf:
+ self.assertEqual(zipf.comment, b"an updated comment")
+
+ # check that comments are correctly shortened in append mode
+ with zipfile.ZipFile(TESTFN,mode="w") as zipf:
+ zipf.comment = b"original comment that's longer"
+ zipf.writestr("foo.txt", "O, for a Muse of Fire!")
+ with zipfile.ZipFile(TESTFN,mode="a") as zipf:
+ zipf.comment = b"shorter comment"
+ with zipfile.ZipFile(TESTFN,mode="r") as zipf:
+ self.assertEqual(zipf.comment, b"shorter comment")
+
def test_unicode_comment(self):
with zipfile.ZipFile(TESTFN, "w", zipfile.ZIP_STORED) as zipf:
zipf.writestr("foo.txt", "O, for a Muse of Fire!")
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list