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

Method check_chmod_link

Lib/test/test_os/test_posix.py:1110–1123  ·  view source on GitHub ↗
(self, chmod_func, target, link, **kwargs)

Source from the content-addressed store, hash-verified

1108 self.check_chmod(posix.chmod, target, follow_symlinks=False)
1109
1110 def check_chmod_link(self, chmod_func, target, link, **kwargs):
1111 target_mode = os.stat(target).st_mode
1112 link_mode = os.lstat(link).st_mode
1113 try:
1114 new_mode = target_mode & ~(stat.S_IWOTH | stat.S_IWGRP | stat.S_IWUSR)
1115 chmod_func(link, new_mode, **kwargs)
1116 self.assertEqual(os.stat(target).st_mode, new_mode)
1117 self.assertEqual(os.lstat(link).st_mode, link_mode)
1118 new_mode = target_mode | (stat.S_IWOTH | stat.S_IWGRP | stat.S_IWUSR)
1119 chmod_func(link, new_mode, **kwargs)
1120 self.assertEqual(os.stat(target).st_mode, new_mode)
1121 self.assertEqual(os.lstat(link).st_mode, link_mode)
1122 finally:
1123 posix.chmod(target, target_mode)
1124
1125 def check_lchmod_link(self, chmod_func, target, link, **kwargs):
1126 target_mode = os.stat(target).st_mode

Callers 2

Calls 5

chmod_funcFunction · 0.85
lstatMethod · 0.80
statMethod · 0.45
assertEqualMethod · 0.45
chmodMethod · 0.45

Tested by

no test coverage detected