MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_init_close_fobj

Method test_init_close_fobj

Lib/test/test_tarfile.py:797–814  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 8

assertTrueMethod · 0.80
openFunction · 0.50
joinMethod · 0.45
writeMethod · 0.45
__new__Method · 0.45
__init__Method · 0.45
failMethod · 0.45
unlinkMethod · 0.45

Tested by

no test coverage detected