mirror of
https://github.com/python/cpython.git
synced 2025-08-10 03:49:18 +00:00
gh-118486: Support mkdir(mode=0o700) on Windows (GH-118488)
This commit is contained in:
parent
c0d257cc69
commit
eb29e2f590
6 changed files with 106 additions and 2 deletions
|
@ -1797,6 +1797,25 @@ class MakedirTests(unittest.TestCase):
|
|||
self.assertRaises(OSError, os.makedirs, path, exist_ok=True)
|
||||
os.remove(path)
|
||||
|
||||
@unittest.skipUnless(os.name == 'nt', "requires Windows")
|
||||
def test_win32_mkdir_700(self):
|
||||
base = os_helper.TESTFN
|
||||
path1 = os.path.join(os_helper.TESTFN, 'dir1')
|
||||
path2 = os.path.join(os_helper.TESTFN, 'dir2')
|
||||
# mode=0o700 is special-cased to override ACLs on Windows
|
||||
# There's no way to know exactly how the ACLs will look, so we'll
|
||||
# check that they are different from a regularly created directory.
|
||||
os.mkdir(path1, mode=0o700)
|
||||
os.mkdir(path2, mode=0o777)
|
||||
|
||||
out1 = subprocess.check_output(["icacls.exe", path1], encoding="oem")
|
||||
out2 = subprocess.check_output(["icacls.exe", path2], encoding="oem")
|
||||
os.rmdir(path1)
|
||||
os.rmdir(path2)
|
||||
out1 = out1.replace(path1, "<PATH>")
|
||||
out2 = out2.replace(path2, "<PATH>")
|
||||
self.assertNotEqual(out1, out2)
|
||||
|
||||
def tearDown(self):
|
||||
path = os.path.join(os_helper.TESTFN, 'dir1', 'dir2', 'dir3',
|
||||
'dir4', 'dir5', 'dir6')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue