MCPcopy Index your code
hub / github.com/python/cpython / test_init_close_fobj

Method test_init_close_fobj

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

Source from the content-addressed store, hash-verified

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

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