#NEWLINE# def test_mock_httpresponse_stream( self ) : #NEWLINE# #INDENT# class MockHTTPRequest ( object ) : #NEWLINE# #INDENT# self . fp = None #NEWLINE# def read( self , amt ) : #NEWLINE# #INDENT# data = self . fp . read ( amt ) #NEWLINE# if ( not data ) : #NEWLINE# #INDENT# self . fp = None #NEWLINE# #UNINDENT# return data #NEWLINE# #UNINDENT# def close( self ) : #NEWLINE# #INDENT# self . fp = None #NEWLINE# #UNINDENT# #UNINDENT# bio = BytesIO ( b'foo' ) #NEWLINE# fp = MockHTTPRequest ( ) #NEWLINE# fp . fp = bio #NEWLINE# resp = HTTPResponse ( fp , preload_content = False ) #NEWLINE# stream = resp . stream ( 2 ) #NEWLINE# self . assertEqual ( next ( stream ) , b'fo' ) #NEWLINE# self . assertEqual ( next ( stream ) , b'o' ) #NEWLINE# self . assertRaises ( StopIteration , next , stream )