def testNoErrorsRelativeOneDir(self): # record, replay os.mkdir('foo') self.mox.ReplayAll() # test, verify file_util.MkDirs('foo') self.mox.VerifyAll()
def testNoErrorsAbsoluteSlashDot(self): # record, replay os.mkdir('/foo') self.mox.ReplayAll() # test, verify file_util.MkDirs('/foo/.') self.mox.VerifyAll()
def testNoErrorsAbsoluteOneDirWithForceMode(self): # record, replay os.mkdir('/foo') os.chmod('/foo', 0707) self.mox.ReplayAll() # test, verify file_util.MkDirs('/foo', force_mode=0707) self.mox.VerifyAll()
def testNoErrorsAbsoluteExcessiveSlashDot(self): """See that normpath removes irrelevant .'s in the path.""" # record, replay os.mkdir('/foo') os.mkdir('/foo/bar') self.mox.ReplayAll() # test, verify file_util.MkDirs('/./foo/./././bar/.') self.mox.VerifyAll()
def testNoErrorsExistingDirWithForceMode(self): exist_error = OSError(errno.EEXIST, 'This string not used') # record, replay os.mkdir('/foo').AndRaise(exist_error) # no chmod is called since the dir exists os.path.isdir('/foo').AndReturn(True) self.mox.ReplayAll() # test, verify file_util.MkDirs('/foo', force_mode=0707) self.mox.VerifyAll()
def testDirectoriesExist(self): exist_error = OSError(errno.EEXIST, 'This string not used') # record, replay for i in range(len(self.dir_tree)): path = os.path.join(*self.dir_tree[:i + 1]) os.mkdir(path).AndRaise(exist_error) os.path.isdir(path).AndReturn(True) self.mox.ReplayAll() # test, verify file_util.MkDirs(os.path.join(*self.dir_tree)) self.mox.VerifyAll()
def testNoErrorsPartialTwoDirsWithForceMode(self): exist_error = OSError(errno.EEXIST, 'This string not used') # record, replay os.mkdir('/foo').AndRaise(exist_error) # /foo exists os.path.isdir('/foo').AndReturn(True) os.mkdir('/foo/bar') # bar does not os.chmod('/foo/bar', 0707) self.mox.ReplayAll() # test, verify file_util.MkDirs('/foo/bar', force_mode=0707) self.mox.VerifyAll()