Change the specs for readinto() -- it should *not* shorten the buffer to

the amount of data read.
This commit is contained in:
Guido van Rossum 2007-03-07 05:23:25 +00:00
parent 01a2752d19
commit 00efeadbcf
2 changed files with 16 additions and 7 deletions

View file

@ -70,10 +70,13 @@ class IOTest(unittest.TestCase):
def read_ops(self, f):
data = f.read(5)
self.assertEqual(data, b"hello")
f.readinto(data)
n = f.readinto(data)
self.assertEqual(n, 5)
self.assertEqual(data, b" worl")
f.readinto(data)
self.assertEqual(data, b"d\n")
n = f.readinto(data)
self.assertEqual(n, 2)
self.assertEqual(len(data), 5)
self.assertEqual(data[:2], b"d\n")
f.seek(0)
self.assertEqual(f.read(20), b"hello world\n")
f.seek(-6, 2)