| 2251 | self.assertEqual(zipf.comment, b"this is a comment") |
| 2252 | |
| 2253 | def test_empty_zipfile(self): |
| 2254 | # Check that creating a file in 'w' or 'a' mode and closing without |
| 2255 | # adding any files to the archives creates a valid empty ZIP file |
| 2256 | zipf = zipfile.ZipFile(TESTFN, mode="w") |
| 2257 | zipf.close() |
| 2258 | try: |
| 2259 | zipf = zipfile.ZipFile(TESTFN, mode="r") |
| 2260 | except zipfile.BadZipFile: |
| 2261 | self.fail("Unable to create empty ZIP file in 'w' mode") |
| 2262 | zipf.close() |
| 2263 | |
| 2264 | zipf = zipfile.ZipFile(TESTFN, mode="a") |
| 2265 | zipf.close() |
| 2266 | try: |
| 2267 | zipf = zipfile.ZipFile(TESTFN, mode="r") |
| 2268 | except: |
| 2269 | self.fail("Unable to create empty ZIP file in 'a' mode") |
| 2270 | zipf.close() |
| 2271 | |
| 2272 | def test_open_empty_file(self): |
| 2273 | # Issue 1710703: Check that opening a file with less than 22 bytes |