Пример #1
0
 def test_basic(self):
     path = self.nextTempFilePath()
     writer = Storage.ChecksummedWriter(path)
     toWrite = ['asdfasdfasdf', 'asdfasdfasdfasdfasdf', 'asdfsdfikjlkhjgkl']
     for string in toWrite:
         writer.writeString(string)
     writer.flush()
     self.assertEqual(writer.written(), writer.fileSize())
     self.assertEqual(
         writer.written(),
         sum(
             len(x) + struct.calcsize(crcType) + struct.calcsize(sizeType)
             for x in toWrite))
     self.assertEqual(writer.path(), path)
     self.assertEqual(os.stat(path).st_size, writer.written())
     success, contents = Storage.readToVector(path)
     self.assertTrue(success)
     self.assertEqual(tuple(toWrite), tuple(contents))
     os.unlink(path)