Exemple #1
0
 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 ))
Exemple #2
0
 def testWrite(self):
     buf = Buffer()
     buf.write(self.test_string)
     self.assertEquals(self.test_string, buf.getvalue())
Exemple #3
0
 def testWriteLong(self):
     tester = 's' * 65537
     buf = Buffer()
     buf.write(tester)
     self.assertEquals(tester, buf.getvalue())
Exemple #4
0
 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))
Exemple #5
0
 def testGetValue(self):
     buf = Buffer(self.test_string)
     self.assertEquals(self.test_string, buf.getvalue())
Exemple #6
0
 def testReadLongRaisesException(self):
     buf = Buffer(self.test_string)
     self.assertRaises(BufferError, buf.read, (len(self.test_string) + 1))
Exemple #7
0
 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))
Exemple #8
0
 def testReadFromWriteRaisesException(self):
     buf = Buffer()
     self.assertRaises(BufferError, buf.read, 1)
Exemple #9
0
 def testWriteFromReadRaisesException(self):
     buf = Buffer(self.test_string)
     self.assertRaises(BufferError, buf.write, self.test_string)
Exemple #10
0
 def testWriteNonStringRaisesException(self):
     buf = Buffer()
     self.assertRaises(BufferError, buf.write, (len(self.test_string)))
Exemple #11
0
 def testWriteLong(self):
     tester = 's' * 65537
     buf = Buffer()
     buf.write(tester)
     self.assertEquals(tester, buf.getvalue())
Exemple #12
0
 def testWrite(self):
     buf = Buffer()
     buf.write(self.test_string)
     self.assertEquals(self.test_string, buf.getvalue())
Exemple #13
0
 def testGetValue(self):
     buf = Buffer(self.test_string)
     self.assertEquals(self.test_string, buf.getvalue())
Exemple #14
0
 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))