Skip to content

Commit 0e2d157

Browse files
committed
move test to MiscTest
1 parent 491b40f commit 0e2d157

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

Lib/test/test_tarfile.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1679,32 +1679,6 @@ def test_missing_fileobj(self):
16791679
with self.assertRaises(ValueError):
16801680
tar.addfile(tarinfo)
16811681

1682-
@unittest.skipUnless(os_helper.can_symlink(), 'requires symlink support')
1683-
@unittest.skipUnless(hasattr(os, 'chmod'), "missing os.chmod")
1684-
@unittest.mock.patch('os.chmod')
1685-
def test_deferred_directory_attributes_update(self, mock_chmod):
1686-
# Regression test for gh-127987: setting attributes on arbitrary files
1687-
tempdir = os.path.join(TEMPDIR, 'test127987')
1688-
def mock_chmod_side_effect(path, mode, **kwargs):
1689-
target_path = os.path.realpath(path)
1690-
if os.path.commonpath([target_path, tempdir]) != tempdir:
1691-
raise Exception("should not try to chmod anything outside the destination", target_path)
1692-
mock_chmod.side_effect = mock_chmod_side_effect
1693-
1694-
outside_tree_dir = os.path.join(TEMPDIR, 'outside_tree_dir')
1695-
with ArchiveMaker() as arc:
1696-
arc.add('x', symlink_to='.')
1697-
arc.add('x', type=tarfile.DIRTYPE, mode='?rwsrwsrwt')
1698-
arc.add('x', symlink_to=('y/' + '../' + outside_tree_dir))
1699-
arc.add('y/', symlink_to=('../' * len(tempdir.split(os.path.sep))))
1700-
1701-
os.makedirs(outside_tree_dir)
1702-
try:
1703-
arc.open().extractall(path=tempdir, filter='tar')
1704-
finally:
1705-
os_helper.rmtree(outside_tree_dir)
1706-
os_helper.rmtree(tempdir)
1707-
17081682

17091683
class GzipWriteTest(GzipTest, WriteTest):
17101684
pass
@@ -2741,6 +2715,32 @@ def test_useful_error_message_when_modules_missing(self):
27412715
str(excinfo.exception),
27422716
)
27432717

2718+
@unittest.skipUnless(os_helper.can_symlink(), 'requires symlink support')
2719+
@unittest.skipUnless(hasattr(os, 'chmod'), "missing os.chmod")
2720+
@unittest.mock.patch('os.chmod')
2721+
def test_deferred_directory_attributes_update(self, mock_chmod):
2722+
# Regression test for gh-127987: setting attributes on arbitrary files
2723+
tempdir = os.path.join(TEMPDIR, 'test127987')
2724+
def mock_chmod_side_effect(path, mode, **kwargs):
2725+
target_path = os.path.realpath(path)
2726+
if os.path.commonpath([target_path, tempdir]) != tempdir:
2727+
raise Exception("should not try to chmod anything outside the destination", target_path)
2728+
mock_chmod.side_effect = mock_chmod_side_effect
2729+
2730+
outside_tree_dir = os.path.join(TEMPDIR, 'outside_tree_dir')
2731+
with ArchiveMaker() as arc:
2732+
arc.add('x', symlink_to='.')
2733+
arc.add('x', type=tarfile.DIRTYPE, mode='?rwsrwsrwt')
2734+
arc.add('x', symlink_to=('y/' + '../' + outside_tree_dir))
2735+
arc.add('y/', symlink_to=('../' * len(tempdir.split(os.path.sep))))
2736+
2737+
os.makedirs(outside_tree_dir)
2738+
try:
2739+
arc.open().extractall(path=tempdir, filter='tar')
2740+
finally:
2741+
os_helper.rmtree(outside_tree_dir)
2742+
os_helper.rmtree(tempdir)
2743+
27442744

27452745
class CommandLineTest(unittest.TestCase):
27462746

0 commit comments

Comments
 (0)