def test_vfs_write_stream(self): vfs = VirtualFileSystem(root_path=".", readonly=False) with vfs.open_write("unittest.txt") as f: f.write("test write") self.assertEqual("test write", vfs["unittest.txt"].text) with vfs.open_write("unittest.txt", append=False) as f: f.write("overwritten") self.assertEqual("overwritten", vfs["unittest.txt"].text) with vfs.open_write("unittest.txt", append=True) as f: f.write("appended") self.assertEqual("overwrittenappended", vfs["unittest.txt"].text) del vfs["unittest.txt"]
def test_vfs_write_stream(self): vfs = VirtualFileSystem(root_path=".", readonly=False) with vfs.open_write("unittest.txt") as f: f.write("test write") self.assertEqual("test write", vfs["unittest.txt"].text) with vfs.open_write("unittest.txt", append=False) as f: f.write("overwritten") self.assertEqual("overwritten", vfs["unittest.txt"].text) with vfs.open_write("unittest.txt", append=True) as f: f.write("appended") self.assertEqual("overwrittenappended", vfs["unittest.txt"].text) del vfs["unittest.txt"]
def test_vfs_readonly(self): vfs = VirtualFileSystem(root_path=".") with self.assertRaises(VfsError): vfs.open_write("test.txt") with self.assertRaises(VfsError): vfs["test.txt"] = "data"
def test_vfs_readonly(self): vfs = VirtualFileSystem(root_path=".") with self.assertRaises(VfsError): vfs.open_write("test.txt") with self.assertRaises(VfsError): vfs["test.txt"] = "data"