| 758 | |
| 759 | @os_helper.skip_unless_working_chmod |
| 760 | def test_extract_directory(self): |
| 761 | dirtype = "ustar/dirtype" |
| 762 | DIR = os.path.join(TEMPDIR, "extractdir") |
| 763 | os.mkdir(DIR) |
| 764 | try: |
| 765 | with tarfile.open(tarname, encoding="iso8859-1") as tar: |
| 766 | tarinfo = tar.getmember(dirtype) |
| 767 | tar.extract(tarinfo, path=DIR, filter='fully_trusted') |
| 768 | extracted = os.path.join(DIR, dirtype) |
| 769 | self.assertEqual(os.path.getmtime(extracted), tarinfo.mtime) |
| 770 | if sys.platform != "win32": |
| 771 | self.assertEqual(os.stat(extracted).st_mode & 0o777, 0o755) |
| 772 | finally: |
| 773 | os_helper.rmtree(DIR) |
| 774 | |
| 775 | def test_extractall_pathlike_dir(self): |
| 776 | DIR = os.path.join(TEMPDIR, "extractall") |