summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_os.py
diff options
context:
space:
mode:
authorSteve Dower <steve.dower@python.org>2024-05-02 14:20:43 (GMT)
committerGitHub <noreply@github.com>2024-05-02 14:20:43 (GMT)
commit81939dad77001556c527485d31a2d0f4a759033e (patch)
treec494f3abbfdc01dc931ef6edcaa9ed4bf0480951 /Lib/test/test_os.py
parentb3372481b6cae5766330b041c4622c28cee2119f (diff)
downloadcpython-81939dad77001556c527485d31a2d0f4a759033e.zip
cpython-81939dad77001556c527485d31a2d0f4a759033e.tar.gz
cpython-81939dad77001556c527485d31a2d0f4a759033e.tar.bz2
gh-118486: Support mkdir(mode=0o700) on Windows (GH-118488)
Diffstat (limited to 'Lib/test/test_os.py')
-rw-r--r--Lib/test/test_os.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
index eaa6766..9c9c853 100644
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -1811,6 +1811,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')