def testRead(self): buf = Buffer(self.test_string) self.assertEquals(self.test_string[0], buf.read(1)) self.assertEquals(1, buf.tell()) self.assertEquals(self.test_string[1:len(self.test_string)], buf.read(len(self.test_string) - 1 ))
def testWrite(self): buf = Buffer() buf.write(self.test_string) self.assertEquals(self.test_string, buf.getvalue())
def testWriteLong(self): tester = 's' * 65537 buf = Buffer() buf.write(tester) self.assertEquals(tester, buf.getvalue())
def testSeek(self): buf = Buffer(self.test_string) buf.seek(len(self.test_string) - 1) self.assertEquals(self.test_string[-1], buf.read(1)) buf.seek(0) self.assertEquals(self.test_string[0], buf.read(1))
def testGetValue(self): buf = Buffer(self.test_string) self.assertEquals(self.test_string, buf.getvalue())
def testReadLongRaisesException(self): buf = Buffer(self.test_string) self.assertRaises(BufferError, buf.read, (len(self.test_string) + 1))
def testRead(self): buf = Buffer(self.test_string) self.assertEquals(self.test_string[0], buf.read(1)) self.assertEquals(1, buf.tell()) self.assertEquals(self.test_string[1:len(self.test_string)], buf.read(len(self.test_string) - 1))
def testReadFromWriteRaisesException(self): buf = Buffer() self.assertRaises(BufferError, buf.read, 1)
def testWriteFromReadRaisesException(self): buf = Buffer(self.test_string) self.assertRaises(BufferError, buf.write, self.test_string)
def testWriteNonStringRaisesException(self): buf = Buffer() self.assertRaises(BufferError, buf.write, (len(self.test_string)))