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

Method test_extractall

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

Source from the content-addressed store, hash-verified

708
709 @os_helper.skip_unless_working_chmod
710 def test_extractall(self):
711 # Test if extractall() correctly restores directory permissions
712 # and times (see issue1735).
713 tar = tarfile.open(tarname, encoding="iso8859-1")
714 DIR = os.path.join(TEMPDIR, "extractall")
715 os.mkdir(DIR)
716 try:
717 directories = [t for t in tar if t.isdir()]
718 tar.extractall(DIR, directories, filter='fully_trusted')
719 for tarinfo in directories:
720 path = os.path.join(DIR, tarinfo.name)
721 if sys.platform != "win32":
722 # Win32 has no support for fine grained permissions.
723 self.assertEqual(tarinfo.mode & 0o777,
724 os.stat(path).st_mode & 0o777,
725 tarinfo.name)
726 def format_mtime(mtime):
727 if isinstance(mtime, float):
728 return "{} ({})".format(mtime, mtime.hex())
729 else:
730 return "{!r} (int)".format(mtime)
731 file_mtime = os.path.getmtime(path)
732 errmsg = "tar mtime {0} != file time {1} of path {2!a}".format(
733 format_mtime(tarinfo.mtime),
734 format_mtime(file_mtime),
735 path)
736 self.assertEqual(tarinfo.mtime, file_mtime, errmsg)
737 finally:
738 tar.close()
739 os_helper.rmtree(DIR)
740
741 @staticmethod
742 def test_extractall_default_filter():

Callers

nothing calls this directly

Calls 9

openMethod · 0.45
joinMethod · 0.45
mkdirMethod · 0.45
isdirMethod · 0.45
extractallMethod · 0.45
assertEqualMethod · 0.45
statMethod · 0.45
formatMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected