Skip to content
Browse files

Return self in makedirs_p even if the path already exists

  • Loading branch information...
1 parent d6a3a2c commit 6032fcfe8a24d78d5294628cd99ec90fb4c6de40 @xentac xentac committed Nov 13, 2012
Showing with 7 additions and 1 deletion.
  1. +2 −1 path.py
  2. +5 −0 test_path.py
View
3 path.py
@@ -917,10 +917,11 @@ def makedirs(self, mode=0777):
def makedirs_p(self, mode=0777):
try:
- return self.makedirs(mode)
+ self.makedirs(mode)
except OSError, e:
if e.errno != errno.EEXIST:
raise
+ return self
def rmdir(self):
os.rmdir(self)
View
5 test_path.py
@@ -144,6 +144,11 @@ def testMakedirs_pReturnsSelf(self):
ret = p.makedirs_p()
self.assertEquals(p, ret)
+ def testMakedirs_pReturnsSelfEvenIfExists(self):
+ p = path(self.tempdir)
+ ret = p.makedirs_p()
+ self.assertEquals(p, ret)
+
class TempDirTestCase(unittest.TestCase):
def setUp(self):
# Create a temporary directory.

0 comments on commit 6032fcf

Please sign in to comment.
Something went wrong with that request. Please try again.