[Python-checkins] r84861 - in python/branches/py3k/Lib/distutils: dir_util.py tests/test_dir_util.py

senthil.kumaran python-checkins at python.org
Fri Sep 17 18:35:37 CEST 2010


Author: senthil.kumaran
Date: Fri Sep 17 18:35:37 2010
New Revision: 84861

Log:
Fix Issue2236: Distutils' mkpath implementation ignoring the "mode" parameter



Modified:
   python/branches/py3k/Lib/distutils/dir_util.py
   python/branches/py3k/Lib/distutils/tests/test_dir_util.py

Modified: python/branches/py3k/Lib/distutils/dir_util.py
==============================================================================
--- python/branches/py3k/Lib/distutils/dir_util.py	(original)
+++ python/branches/py3k/Lib/distutils/dir_util.py	Fri Sep 17 18:35:37 2010
@@ -68,7 +68,7 @@
 
         if not dry_run:
             try:
-                os.mkdir(head)
+                os.mkdir(head, mode)
                 created_dirs.append(head)
             except OSError as exc:
                 raise DistutilsFileError(

Modified: python/branches/py3k/Lib/distutils/tests/test_dir_util.py
==============================================================================
--- python/branches/py3k/Lib/distutils/tests/test_dir_util.py	(original)
+++ python/branches/py3k/Lib/distutils/tests/test_dir_util.py	Fri Sep 17 18:35:37 2010
@@ -1,6 +1,7 @@
 """Tests for distutils.dir_util."""
 import unittest
 import os
+import stat
 import shutil
 
 from distutils.dir_util import (mkpath, remove_tree, create_tree, copy_tree,
@@ -48,6 +49,12 @@
         wanted = ["removing '%s' (and everything under it)" % self.root_target]
         self.assertEquals(self._logs, wanted)
 
+    def test_mkpath_with_custom_mode(self):
+        mkpath(self.target, 0o700)
+        self.assertEqual(stat.S_IMODE(os.stat(self.target).st_mode), 0o700)
+        mkpath(self.target2, 0o555)
+        self.assertEqual(stat.S_IMODE(os.stat(self.target2).st_mode), 0o555)
+
     def test_create_tree_verbosity(self):
 
         create_tree(self.root_target, ['one', 'two', 'three'], verbose=0)


More information about the Python-checkins mailing list