@@ -979,40 +979,17 @@ def test_realpath_permission(self):
979979 except AssertionError :
980980 raise unittest .SkipTest ('the filesystem seems to lack support for short filenames' )
981981
982+ # Deny the right to [S]YNCHRONIZE on the file to
983+ # force nt._getfinalpathname to fail with ERROR_ACCESS_DENIED.
982984 p = subprocess .run (
983- ['whoami.exe' , '/GROUPS' ],
984- creationflags = subprocess .DETACHED_PROCESS ,
985- capture_output = True ,
986- )
987- if p .returncode :
988- raise unittest .SkipTest ('cannot check group membership' )
989-
990- groups_output = p .stdout
991- groups = (
992- 'S-1-5-32-544' , # Administrators
993- 'S-1-5-32-545' , # Users
985+ ['icacls.exe' , test_file , '/deny' , '*S-1-5-32-545:(S)' ],
986+ creationflags = subprocess .DETACHED_PROCESS
994987 )
995988
996- for group in groups :
997- if group .encode () not in groups_output :
998- continue
999-
1000- # Deny the right to [S]YNCHRONIZE on the file to
1001- # force nt._getfinalpathname to fail with ERROR_ACCESS_DENIED.
1002- p = subprocess .run (
1003- ['icacls.exe' , test_file , '/deny' , f'*{ group } :(S)' ],
1004- creationflags = subprocess .DETACHED_PROCESS
1005- )
1006- if p .returncode == 0 :
1007- break
1008- else :
989+ if p .returncode :
1009990 raise unittest .SkipTest ('failed to deny access to the test file' )
1010991
1011992 self .assertPathEqual (test_file , ntpath .realpath (test_file_short ))
1012- with self .assertRaises (OSError ):
1013- ntpath .realpath (test_file_short , strict = True )
1014- with self .assertRaises (OSError ):
1015- ntpath .realpath (test_file_short , strict = ALLOW_MISSING )
1016993
1017994 def test_expandvars (self ):
1018995 with os_helper .EnvironmentVarGuard () as env :
0 commit comments