diff options
author | Berker Peksag <berker.peksag@gmail.com> | 2016-09-17 12:49:59 (GMT) |
---|---|---|
committer | Berker Peksag <berker.peksag@gmail.com> | 2016-09-17 12:49:59 (GMT) |
commit | 0b4dc4846b603025ee8da4403e87cad7739ac8f7 (patch) | |
tree | 263840dab088cf253ad63b2e670a3195a079734a /Lib | |
parent | 6d57fe1c23430d0d51de243a177670b76c37dab5 (diff) | |
download | cpython-0b4dc4846b603025ee8da4403e87cad7739ac8f7.zip cpython-0b4dc4846b603025ee8da4403e87cad7739ac8f7.tar.gz cpython-0b4dc4846b603025ee8da4403e87cad7739ac8f7.tar.bz2 |
Issue #28075: Check for ERROR_ACCESS_DENIED in Windows implementation of os.stat()
Patch by Eryk Sun.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_os.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py index a1046b7..9189a82 100644 --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -432,6 +432,25 @@ class StatAttributeTests(unittest.TestCase): result.st_file_attributes & stat.FILE_ATTRIBUTE_DIRECTORY, stat.FILE_ATTRIBUTE_DIRECTORY) + @unittest.skipUnless(sys.platform == "win32", "Win32 specific tests") + def test_access_denied(self): + # Default to FindFirstFile WIN32_FIND_DATA when access is + # denied. See issue 28075. + # os.environ['TEMP'] should be located on a volume that + # supports file ACLs. + fname = os.path.join(os.environ['TEMP'], self.fname) + self.addCleanup(support.unlink, fname) + create_file(fname, b'ABC') + # Deny the right to [S]YNCHRONIZE on the file to + # force CreateFile to fail with ERROR_ACCESS_DENIED. + DETACHED_PROCESS = 8 + subprocess.check_call( + ['icacls.exe', fname, '/deny', 'Users:(S)'], + creationflags=DETACHED_PROCESS + ) + result = os.stat(fname) + self.assertNotEqual(result.st_size, 0) + class UtimeTests(unittest.TestCase): def setUp(self): |