@@ -3076,6 +3076,25 @@ def test_dup2_with_new_fd(self):
30763076 self .assertEqual (fd1 + 1 , fd3 )
30773077 self .assertEqual (fd1 + 3 , fd4 )
30783078
3079+ @unittest .skipIf (sys .version_info < (3 , 14 ), "Introduced in Python 3.14" )
3080+ def test_readinto (self ):
3081+ file_path = self .make_path ("foo" , "bar.txt" )
3082+ contents = b"Testing readinto"
3083+ self .create_file (file_path , contents = contents )
3084+ fd = self .os .open (file_path , os .O_RDONLY )
3085+ try :
3086+ buffer = bytearray (b"" )
3087+ self .assertEqual (0 , self .os .readinto (fd , buffer ))
3088+ buffer = bytearray (b" " * 20 )
3089+ self .assertEqual (len (contents ), self .os .readinto (fd , buffer ))
3090+ self .assertEqual (b"Testing readinto " , buffer )
3091+ self .assertEqual (0 , self .os .readinto (fd , buffer ))
3092+ self .os .lseek (fd , 5 , os .SEEK_SET )
3093+ self .assertEqual (len (contents ) - 5 , self .os .readinto (fd , buffer ))
3094+ self .assertEqual (b"ng readintodinto " , buffer )
3095+ finally :
3096+ self .os .close (fd )
3097+
30793098
30803099class RealOsModuleTest (FakeOsModuleTest ):
30813100 def use_real_fs (self ):
0 commit comments