#NEWLINE# def test_readinto( self ) : #NEWLINE# #INDENT# buf = self . buftype ( '1234567890' ) #NEWLINE# memio = self . ioclass ( buf ) #NEWLINE# b = bytearray ( b'hello' ) #NEWLINE# self . assertEqual ( memio . readinto ( b ) , 5 ) #NEWLINE# self . assertEqual ( b , b'12345' ) #NEWLINE# self . assertEqual ( memio . readinto ( b ) , 5 ) #NEWLINE# self . assertEqual ( b , b'67890' ) #NEWLINE# self . assertEqual ( memio . readinto ( b ) , 0 ) #NEWLINE# self . assertEqual ( b , b'67890' ) #NEWLINE# b = bytearray ( b'hello world' ) #NEWLINE# memio . seek ( 0 ) #NEWLINE# self . assertEqual ( memio . readinto ( b ) , 10 ) #NEWLINE# self . assertEqual ( b , b'1234567890d' ) #NEWLINE# b = bytearray ( b'' ) #NEWLINE# memio . seek ( 0 ) #NEWLINE# self . assertEqual ( memio . readinto ( b ) , 0 ) #NEWLINE# self . assertEqual ( memio , b'' ) #NEWLINE# self . assertRaises ( TypeError , memio . readinto , '' ) #NEWLINE# import array #NEWLINE# a = array . array ( 'b' , b'hello world' ) #NEWLINE# memio = self . ioclass ( buf ) #NEWLINE# memio . readinto ( a ) #NEWLINE# self . assertEqual ( a . tobytes ( ) , b'1234567890d' ) #NEWLINE# memio . close ( ) #NEWLINE# self . assertRaises ( ValueError , memio . readinto , b ) #NEWLINE# memio = self . ioclass ( b'123' ) #NEWLINE# b = bytearray ( ) #NEWLINE# memio . seek ( 42 ) #NEWLINE# memio . readinto ( b ) #NEWLINE# self . assertEqual ( b , b'' )