def test_rwlocalfile4(self): """test direct write_back (no previous read, write etc.)""" path = self.fixture_file('remotefile2') f = RWLocalFile(path, wb_path='/source/prj/pkg/remotefile2', append=True) f.write_back(force=True) f.close()
def test_rwlocalfile3(self): """use existing file""" path = self.fixture_file('remotefile2') self.assertTrue(os.path.exists(path)) f = RWLocalFile(path, wb_path='/source/prj/pkg/remotefile2', append=True) f.write(' testcase\n') f.flush() with open(path, 'r') as fobj: exp = 'yet another\nsimple\nfile\n testcase\n' self.assertEqual(fobj.read(), exp) f.write_back() f.close()
def test_rwlocalfile1(self): """test simple read write (file does not exist)""" path = self.fixture_file('doesnotexist') self.assertFalse(os.path.exists(path)) f = RWLocalFile(path, wb_path='/foo/bar') f.write('some data') f.flush() self.assertTrue(os.path.isfile(path)) with open(path, 'r') as fobj: self.assertEqual(fobj.read(), 'some data') f.seek(0, os.SEEK_SET) self.assertEqual(f.read(), 'some data') f.write_back(foo='bar') f.close()