diff options
| author | Matthias Klose <doko@ubuntu.com> | 2012-06-30 16:26:26 (GMT) |
|---|---|---|
| committer | Matthias Klose <doko@ubuntu.com> | 2012-06-30 16:26:26 (GMT) |
| commit | fe39bd12f8a37f3bfcbbcc52fba49841053e1682 (patch) | |
| tree | 6eb163bfdfca3310623b3494d9b5e4dd8864c376 /Lib/test | |
| parent | 5884449539510313c826d69835829c7957c7154a (diff) | |
| parent | 3746aee9059567b5199051a5147aecbecb6a5acf (diff) | |
| download | cpython-fe39bd12f8a37f3bfcbbcc52fba49841053e1682.zip cpython-fe39bd12f8a37f3bfcbbcc52fba49841053e1682.tar.gz cpython-fe39bd12f8a37f3bfcbbcc52fba49841053e1682.tar.bz2 | |
- merge branches
Diffstat (limited to 'Lib/test')
| -rw-r--r-- | 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 index 0772236..2e52c68 100644 --- a/Lib/test/test_zipfile.py +++ b/Lib/test/test_zipfile.py @@ -1134,6 +1134,24 @@ class OtherTests(unittest.TestCase): 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!") |
