diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2013-12-16 19:22:37 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2013-12-16 19:22:37 (GMT) |
commit | 0048c98fef96fa5df30db535bc124ee9aac341b0 (patch) | |
tree | 70c4cd0630369a5aef472813c185fa8e8466ae47 /Lib/test/test_pathlib.py | |
parent | c274fd22edd2471b4f73f5cc690851cfbc716589 (diff) | |
download | cpython-0048c98fef96fa5df30db535bc124ee9aac341b0.zip cpython-0048c98fef96fa5df30db535bc124ee9aac341b0.tar.gz cpython-0048c98fef96fa5df30db535bc124ee9aac341b0.tar.bz2 |
Issue #19921: When Path.mkdir() is called with parents=True, any missing parent is created with the default permissions, ignoring the mode argument (mimicking the POSIX "mkdir -p" command).
Patch by Serhiy.
Diffstat (limited to 'Lib/test/test_pathlib.py')
-rwxr-xr-x | Lib/test/test_pathlib.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py index 0ad77e0..bdcba9f 100755 --- a/Lib/test/test_pathlib.py +++ b/Lib/test/test_pathlib.py @@ -1478,7 +1478,6 @@ class _BasePathTest(object): with self.assertRaises(OSError) as cm: p.mkdir() self.assertEqual(cm.exception.errno, errno.EEXIST) - # XXX test `mode` arg def test_mkdir_parents(self): # Creating a chain of directories @@ -1493,7 +1492,17 @@ class _BasePathTest(object): with self.assertRaises(OSError) as cm: p.mkdir(parents=True) self.assertEqual(cm.exception.errno, errno.EEXIST) - # XXX test `mode` arg + # test `mode` arg + mode = stat.S_IMODE(p.stat().st_mode) # default mode + p = self.cls(BASE, 'newdirD', 'newdirE') + p.mkdir(0o555, parents=True) + self.assertTrue(p.exists()) + self.assertTrue(p.is_dir()) + if os.name != 'nt': + # the directory's permissions follow the mode argument + self.assertEqual(stat.S_IMODE(p.stat().st_mode), 0o555 & mode) + # the parent's permissions follow the default process settings + self.assertEqual(stat.S_IMODE(p.parent.stat().st_mode), mode) @with_symlinks def test_symlink_to(self): |