Skip to content

Commit

Permalink
Merge pull request #341 from topazproject/tim/Dir.mkdir
Browse files Browse the repository at this point in the history
Add Dir.mkdir
  • Loading branch information
alex committed Feb 11, 2013
2 parents da0529e + 9df97fa commit 571fbc7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests/objects/test_dirobject.py
Expand Up @@ -33,6 +33,10 @@ def test_delete(self, space, tmpdir):
with self.raises(space, "SystemCallError"):
space.execute("Dir.delete('%s')" % d)

def test_mkdir(self, space, tmpdir):
space.execute("Dir.mkdir(File.join('%s', 'madedir'))" % tmpdir)
assert os.path.join(str(tmpdir), "madedir") in [str(d) for d in tmpdir.listdir()]

def test_chdir(self, space, tmpdir, monkeypatch):
w_res = space.execute("""
dirs = []
Expand Down
8 changes: 8 additions & 0 deletions topaz/objects/dirobject.py
Expand Up @@ -113,3 +113,11 @@ def method_close(self, space):
closedir(self.dirp)
self.open = False
return space.w_nil

@classdef.singleton_method("mkdir", path="path", mask="int")
def method_mkdir(self, space, path, mask=0022):
try:
os.mkdir(path, mask)
except OSError as e:
raise error_for_oserror(space, e)
return space.newint(0)

0 comments on commit 571fbc7

Please sign in to comment.