class TestFileBlockSource(unittest.TestCase): def setUp(self): self.__fileBlockSource = FileBlockSource(blockSize=8) self.__dirPath = os.path.abspath(os.curdir) def testGetSource(self): filePath = os.path.join(self.__dirPath, "resources/test_read_file") source = self.__fileBlockSource.openSource(filePath) self.assertIsNotNone(source, "not open source") self.__fileBlockSource.closeSource(source) def testGetSourceThrowIOError(self): filePath = os.path.join(self.__dirPath, "resources/not_exist_file") self.assertRaises(IOError, self.__fileBlockSource.openSource, filePath) def testRead(self): filePath = os.path.join(self.__dirPath, "resources/test_read_file") source = self.__fileBlockSource.openSource(filePath) for block in self.__fileBlockSource.read(source): self.assertIsNotNone(block) self.__fileBlockSource.closeSource(source)
class TestFileBlockSource(unittest.TestCase): def setUp(self): self.__fileBlockSource = FileBlockSource(blockSize=8) self.__dirPath = os.path.abspath(os.curdir) def testGetSource(self): filePath = os.path.join(self.__dirPath, "resources/test_read_file") source = self.__fileBlockSource.openSource(filePath) self.assertIsNotNone(source, "not open source") self.__fileBlockSource.closeSource(source) def testGetSourceThrowIOError(self): filePath = os.path.join(self.__dirPath, "resources/not_exist_file") self.assertRaises(IOError, self.__fileBlockSource.openSource, filePath) def testRead(self): filePath = os.path.join(self.__dirPath, "resources/test_read_file") source = self.__fileBlockSource.openSource(filePath) for block in self.__fileBlockSource.read(source): self.assertIsNotNone(block) self.__fileBlockSource.closeSource(source)