| 793 | self.assertEqual(os.path.getmtime(extracted), tarinfo.mtime) |
| 794 | |
| 795 | def test_init_close_fobj(self): |
| 796 | # Issue #7341: Close the internal file object in the TarFile |
| 797 | # constructor in case of an error. For the test we rely on |
| 798 | # the fact that opening an empty file raises a ReadError. |
| 799 | empty = os.path.join(TEMPDIR, "empty") |
| 800 | with open(empty, "wb") as fobj: |
| 801 | fobj.write(b"") |
| 802 | |
| 803 | try: |
| 804 | tar = object.__new__(tarfile.TarFile) |
| 805 | try: |
| 806 | tar.__init__(empty) |
| 807 | except tarfile.ReadError: |
| 808 | self.assertTrue(tar.fileobj.closed) |
| 809 | else: |
| 810 | self.fail("ReadError not raised") |
| 811 | finally: |
| 812 | os_helper.unlink(empty) |
| 813 | |
| 814 | def test_parallel_iteration(self): |
| 815 | # Issue #16601: Restarting iteration over tarfile continued |