MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_access_denied

Method test_access_denied

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

Source from the content-addressed store, hash-verified

844
845 @unittest.skipUnless(sys.platform == "win32", "Win32 specific tests")
846 def test_access_denied(self):
847 # Default to FindFirstFile WIN32_FIND_DATA when access is
848 # denied. See issue 28075.
849 # os.environ['TEMP'] should be located on a volume that
850 # supports file ACLs.
851 fname = os.path.join(os.environ['TEMP'], self.fname + "_access")
852 self.addCleanup(os_helper.unlink, fname)
853 create_file(fname, b'ABC')
854 # Deny the right to [S]YNCHRONIZE on the file to
855 # force CreateFile to fail with ERROR_ACCESS_DENIED.
856 DETACHED_PROCESS = 8
857 subprocess.check_call(
858 # bpo-30584: Use security identifier *S-1-5-32-545 instead
859 # of localized "Users" to not depend on the locale.
860 ['icacls.exe', fname, '/deny', '*S-1-5-32-545:(S)'],
861 creationflags=DETACHED_PROCESS
862 )
863 result = os.stat(fname)
864 self.assertNotEqual(result.st_size, 0)
865 self.assertTrue(os.path.isfile(fname))
866
867 @unittest.skipUnless(sys.platform == "win32", "Win32 specific tests")
868 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