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

Method test_extractall

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

Source from the content-addressed store, hash-verified

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