def test_vfs_storage(self): vfs = VirtualFileSystem(util) with vfs.open_write("unittest.txt") as f: f.write("test") with self.assertRaises(IOError): vfs.load_from_storage("test_doesnt_exist_999.txt") vfs.write_to_storage("unittest.txt", b"Test1\nTest2\n") self.assertEqual(b"Test1\nTest2\n", vfs.load_from_storage("unittest.txt")) vfs.delete_storage("unittest.txt")
def test_vfs_load(self): vfs = VirtualFileSystem(util) with self.assertRaises(VfsError): vfs.load_text("a\\b") with self.assertRaises(VfsError): vfs.load_text("/abs/path") with self.assertRaises(IOError): vfs.load_text("normal/text") with self.assertRaises(IOError): vfs.load_image("normal/image") vfs = VirtualFileSystem("/var/temp") with self.assertRaises(IOError): vfs.load_text("test_doesnt_exist_999.txt")