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

Method test_access_denied

Lib/test/test_os/test_os.py:1005–1024  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1003
1004 @unittest.skipUnless(sys.platform == "win32", "Win32 specific tests")
1005 def test_access_denied(self):
1006 # Default to FindFirstFile WIN32_FIND_DATA when access is
1007 # denied. See issue 28075.
1008 # os.environ['TEMP'] should be located on a volume that
1009 # supports file ACLs.
1010 fname = os.path.join(os.environ['TEMP'], self.fname + "_access")
1011 self.addCleanup(os_helper.unlink, fname)
1012 create_file(fname, b'ABC')
1013 # Deny the right to [S]YNCHRONIZE on the file to
1014 # force CreateFile to fail with ERROR_ACCESS_DENIED.
1015 DETACHED_PROCESS = 8
1016 subprocess.check_call(
1017 # bpo-30584: Use security identifier *S-1-5-32-545 instead
1018 # of localized "Users" to not depend on the locale.
1019 ['icacls.exe', fname, '/deny', '*S-1-5-32-545:(S)'],
1020 creationflags=DETACHED_PROCESS
1021 )
1022 result = os.stat(fname)
1023 self.assertNotEqual(result.st_size, 0)
1024 self.assertTrue(os.path.isfile(fname))
1025
1026 @unittest.skipUnless(sys.platform == "win32", "Win32 specific tests")
1027 def test_stat_block_device(self):

Callers

nothing calls this directly

Calls 7

addCleanupMethod · 0.80
assertNotEqualMethod · 0.80
assertTrueMethod · 0.80
create_fileFunction · 0.70
joinMethod · 0.45
statMethod · 0.45
isfileMethod · 0.45

Tested by

no test coverage detected