def test_atomicity(self): testpath = self._test_dir() if self.fs.exists(testpath): self.fs.remove(testpath, skip_trash=True) pipe = hdfs.HdfsAtomicWritePipe(testpath) self.assertFalse(self.fs.exists(testpath)) pipe.close() self.assertTrue(self.fs.exists(testpath))
def test_with_close(self): testpath = "luigi_hdfs_testfile" if hdfs.exists(testpath): hdfs.remove(testpath) with hdfs.HdfsAtomicWritePipe(testpath) as fobj: fobj.write('hej') self.assertTrue(hdfs.exists(testpath))
def test_atomicity(self): testpath = "luigi_hdfs_testfile" if hdfs.exists(testpath): hdfs.remove(testpath) pipe = hdfs.HdfsAtomicWritePipe(testpath) self.assertFalse(hdfs.exists(testpath)) pipe.close() self.assertTrue(hdfs.exists(testpath))
def test_with_close(self): testpath = self._test_file() if self.fs.exists(testpath): self.fs.remove(testpath, skip_trash=True) with hdfs.HdfsAtomicWritePipe(testpath) as fobj: fobj.write('hej') self.assertTrue(self.fs.exists(testpath))
def foo(): with hdfs.HdfsAtomicWritePipe(self.path) as fobj: fobj.write('hej') raise TestException('Test triggered exception')
def test_with_close(self): with hdfs.HdfsAtomicWritePipe(self.path) as fobj: fobj.write('hej') self.assertTrue(self.fs.exists(self.path))