Skip to content

Commit b4b4c28

Browse files
committed
Test zero byte long bytearrays, fix typo
1 parent 6512788 commit b4b4c28

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Lib/test/test_os.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,13 @@ def test_readinto(self):
253253
self.assertEqual(s, 0)
254254
self.assertEqual(bytes(buffer), b"notspam\0")
255255

256+
# Readinto a 0 length bytearray when at EOF should return 0
257+
self.assertEqual(os.readinto(fd, bytearray()), 0)
258+
259+
# Readinto a 0 length bytearray with data available should return 0.
260+
os.lseek(fd, 0, 0)
261+
self.assertEqual(os.readinto(fd, bytearray()), 0)
262+
256263
def test_readinto_badbuffer(self):
257264
with open(os_helper.TESTFN, "w+b") as fobj:
258265
fobj.write(b"spam")
@@ -302,7 +309,7 @@ def test_large_readinto(self, size):
302309
create_file(os_helper.TESTFN, b'test')
303310

304311
# Issue #21932: For readinto the buffer contains the length rather than
305-
# a length being passed explicitly to read, shold still get capped to a
312+
# a length being passed explicitly to read, should still get capped to a
306313
# valid size / not raise an OverflowError for sizes larger than INT_MAX.
307314
buffer = bytearray(INT_MAX+10)
308315
with open(os_helper.TESTFN, "rb") as fp:

0 commit comments

Comments
 (0)