Exemplo n.º 1
0
 def testNoErrorsRelativeOneDir(self):
   # record, replay
   os.mkdir('foo')
   self.mox.ReplayAll()
   # test, verify
   file_util.MkDirs('foo')
   self.mox.VerifyAll()
Exemplo n.º 2
0
 def testNoErrorsAbsoluteSlashDot(self):
   # record, replay
   os.mkdir('/foo')
   self.mox.ReplayAll()
   # test, verify
   file_util.MkDirs('/foo/.')
   self.mox.VerifyAll()
Exemplo n.º 3
0
 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()
Exemplo n.º 4
0
 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()
Exemplo n.º 5
0
 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()
Exemplo n.º 6
0
 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()
Exemplo n.º 7
0
 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()