Serhiy Storchaka <storch...@gmail.com> added the comment:

> Then the tests may still be added to test_zipfile?

Yes, they may. Here is a patch with adapted for 3.3 tests only.

----------
Added file: 
http://bugs.python.org/file26216/zipfile_appendmode_comment_tests.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue9239>
_______________________________________
diff -r 5fea362b92fc Lib/test/test_zipfile.py
--- a/Lib/test/test_zipfile.py  Wed Apr 25 19:45:11 2012 +0200
+++ b/Lib/test/test_zipfile.py  Sat Apr 28 22:16:43 2012 +0300
@@ -970,6 +970,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!")
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to