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

Method test_deferred_directory_attributes_update

Lib/test/test_tarfile.py:2802–2822  ·  view source on GitHub ↗
(self, mock_chmod)

Source from the content-addressed store, hash-verified

2800 @unittest.skipUnless(hasattr(os, 'chmod'), "missing os.chmod")
2801 @unittest.mock.patch('os.chmod')
2802 def test_deferred_directory_attributes_update(self, mock_chmod):
2803 # Regression test for gh-127987: setting attributes on arbitrary files
2804 tempdir = os.path.join(TEMPDIR, 'test127987')
2805 def mock_chmod_side_effect(path, mode, **kwargs):
2806 target_path = os.path.realpath(path)
2807 if os.path.commonpath([target_path, tempdir]) != tempdir:
2808 raise Exception("should not try to chmod anything outside the destination", target_path)
2809 mock_chmod.side_effect = mock_chmod_side_effect
2810
2811 outside_tree_dir = os.path.join(TEMPDIR, 'outside_tree_dir')
2812 with ArchiveMaker() as arc:
2813 arc.add('x', symlink_to='.')
2814 arc.add('x', type=tarfile.DIRTYPE, mode='?rwsrwsrwt')
2815 arc.add('x', symlink_to=outside_tree_dir)
2816
2817 os.makedirs(outside_tree_dir)
2818 try:
2819 arc.open().extractall(path=tempdir, filter='tar')
2820 finally:
2821 os_helper.rmtree(outside_tree_dir)
2822 os_helper.rmtree(tempdir)
2823
2824
2825class CommandLineTest(unittest.TestCase):

Callers

nothing calls this directly

Calls 5

ArchiveMakerClass · 0.85
joinMethod · 0.45
addMethod · 0.45
extractallMethod · 0.45
openMethod · 0.45

Tested by

no test coverage detected