def test_mkdirs(self): try: subdir = os.path.join('/tmp', str(random.random())) path = os.path.join(subdir, str(random.random())) fs.mkdirs(path) assert os.path.exists(path) finally: shutil.rmtree(subdir)
def test_mkdirs_already_dir(self): tmpdir = mkdtemp() try: fs.mkdirs(tmpdir) except (GlusterFileSystemOSError, OSError): self.fail("Unexpected exception") else: pass finally: shutil.rmtree(tmpdir)
def test_mkdirs_existing_file_on_path(self): tmpdir = mkdtemp() fd, tmpfile = mkstemp(dir=tmpdir) try: fs.mkdirs(os.path.join(tmpfile, 'b')) except OSError: pass else: self.fail("Expected GlusterFileSystemOSError exception") finally: os.close(fd) shutil.rmtree(tmpdir)
def test_mkdirs_DiskFileNoSpace(self): with patch('os.makedirs', mock_os_mkdir_makedirs_enospc): try: fs.mkdirs("blah") except DiskFileNoSpace: pass else: self.fail("Expected DiskFileNoSpace exception") with patch('os.makedirs', mock_os_mkdir_makedirs_edquot): try: fs.mkdirs("blah") except DiskFileNoSpace: pass else: self.fail("Expected DiskFileNoSpace exception")