diff options
author | Marcel Plch <gmarcel.plch@gmail.com> | 2018-08-02 13:04:52 (GMT) |
---|---|---|
committer | Victor Stinner <vstinner@redhat.com> | 2018-08-02 13:04:52 (GMT) |
commit | a2fe1e52eb94c41d9ebce1ab284180d7b1faa2a4 (patch) | |
tree | 252fe3c3a784a8c4e68873be4743ba703b551653 /Lib/test/test_zipfile.py | |
parent | fc512e3e0663f7f325862fcd42aef765fd34a453 (diff) | |
download | cpython-a2fe1e52eb94c41d9ebce1ab284180d7b1faa2a4.zip cpython-a2fe1e52eb94c41d9ebce1ab284180d7b1faa2a4.tar.gz cpython-a2fe1e52eb94c41d9ebce1ab284180d7b1faa2a4.tar.bz2 |
bpo-34097: Add support for zipping files older than 1980-01-01 (GH-8270)
ZipFile can zip files older than 1980-01-01 and newer than 2107-12-31 using
a new strict_timestamps parameter at the cost of setting the timestamp
to the limit.
Diffstat (limited to 'Lib/test/test_zipfile.py')
-rw-r--r-- | Lib/test/test_zipfile.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_zipfile.py b/Lib/test/test_zipfile.py index ac9a4ff..3b78b7f 100644 --- a/Lib/test/test_zipfile.py +++ b/Lib/test/test_zipfile.py @@ -549,6 +549,22 @@ class StoredTestsWithSourceFile(AbstractTestsWithSourceFile, with zipfile.ZipFile(TESTFN2, "w") as zipfp: self.assertRaises(ValueError, zipfp.write, TESTFN) + with zipfile.ZipFile(TESTFN2, "w") as zipfp: + zipfp.write(TESTFN, strict_timestamps=False) + zinfo = zipfp.getinfo(TESTFN) + self.assertEqual(zinfo.date_time, (1980, 1, 1, 0, 0, 0)) + + def test_add_file_after_2107(self): + # Set atime and mtime to 2108-12-30 + os.utime(TESTFN, (4386268800, 4386268800)) + with zipfile.ZipFile(TESTFN2, "w") as zipfp: + self.assertRaises(struct.error, zipfp.write, TESTFN) + + with zipfile.ZipFile(TESTFN2, "w") as zipfp: + zipfp.write(TESTFN, strict_timestamps=False) + zinfo = zipfp.getinfo(TESTFN) + self.assertEqual(zinfo.date_time, (2107, 12, 31, 23, 59, 59)) + @requires_zlib class DeflateTestsWithSourceFile(AbstractTestsWithSourceFile, |