Skip to content

Commit 4da3fec

Browse files
committed
Only check set bytes in readinto test
1 parent b4b4c28 commit 4da3fec

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Lib/test/test_os.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -236,22 +236,22 @@ def test_readinto(self):
236236
fobj.flush()
237237
fd = fobj.fileno()
238238
os.lseek(fd, 0, 0)
239-
buffer = bytearray(8)
239+
buffer = bytearray(7)
240240
s = os.readinto(fd, buffer)
241241
self.assertEqual(type(s), int)
242242
self.assertEqual(s, 4)
243243
# Should overwrite the first 4 bytes of the buffer.
244-
self.assertEqual(bytes(buffer), b"spam\0\0\0\0")
244+
self.assertEqual(buffer[:4], b"spam")
245245

246-
# Readinto at EOF shold return 0 and not touch buffer
247-
buffer[:] = b"notspam\0"
246+
# Readinto at EOF should return 0 and not touch buffer.
247+
buffer[:] = b"notspam"
248248
s = os.readinto(fd, buffer)
249249
self.assertEqual(type(s), int)
250250
self.assertEqual(s, 0)
251-
self.assertEqual(bytes(buffer), b"notspam\0")
251+
self.assertEqual(bytes(buffer), b"notspam")
252252
s = os.readinto(fd, buffer)
253253
self.assertEqual(s, 0)
254-
self.assertEqual(bytes(buffer), b"notspam\0")
254+
self.assertEqual(bytes(buffer), b"notspam")
255255

256256
# Readinto a 0 length bytearray when at EOF should return 0
257257
self.assertEqual(os.readinto(fd, bytearray()), 0)

0 commit comments

Comments
 (0)