diff options
author | Jan Mazur <16736821+mzr@users.noreply.github.com> | 2020-09-28 18:53:33 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-28 18:53:33 (GMT) |
commit | ff9147d93b868f0e13b9fe14e2a76c2879f6787b (patch) | |
tree | fbfb36ce08a859c0ce11a8247b311083933f8d3c /Lib/test | |
parent | a195bceff7b552c5f86dec7894ff24dcc87235da (diff) | |
download | cpython-ff9147d93b868f0e13b9fe14e2a76c2879f6787b.zip cpython-ff9147d93b868f0e13b9fe14e2a76c2879f6787b.tar.gz cpython-ff9147d93b868f0e13b9fe14e2a76c2879f6787b.tar.bz2 |
bpo-40105: ZipFile truncate in append mode with shorter comment (GH-19337)
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_zipfile.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Lib/test/test_zipfile.py b/Lib/test/test_zipfile.py index 2851051..687e43d 100644 --- a/Lib/test/test_zipfile.py +++ b/Lib/test/test_zipfile.py @@ -1856,11 +1856,14 @@ class OtherTests(unittest.TestCase): self.assertEqual(zipf.comment, b"an updated comment") # check that comments are correctly shortened in append mode + # and the file is indeed truncated 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!") + original_zip_size = os.path.getsize(TESTFN) with zipfile.ZipFile(TESTFN,mode="a") as zipf: zipf.comment = b"shorter comment" + self.assertTrue(original_zip_size > os.path.getsize(TESTFN)) with zipfile.ZipFile(TESTFN,mode="r") as zipf: self.assertEqual(zipf.comment, b"shorter comment") |