#NEWLINE# @ mock . patch ( 'treq.client.uuid.uuid4' , mock . Mock ( return_value = 'heyDavid' ) ) #NEWLINE# def test_request_mixed_params( self ) : #NEWLINE# #INDENT# class NamedFile ( BytesIO ) : #NEWLINE# #INDENT# def __init__( self , val ) : #NEWLINE# #INDENT# BytesIO . __init__ ( self , val ) #NEWLINE# self . name = 'image.png' #NEWLINE# #UNINDENT# #UNINDENT# self . client . request ( 'POST' , 'http://example.com/' , data = [ ( 'a' , 'b' ) , ( 'key' , 'val' ) ] , files = [ ( 'file1' , ( 'image.jpg' , BytesIO ( b'hello' ) ) ) , ( 'file2' , NamedFile ( b'yo' ) ) ] ) #NEWLINE# self . agent . request . assert_called_once_with ( b'POST' , b'http://example.com/' , Headers ( { #NEWLINE# #INDENT# b'accept-encoding' : [ b'gzip' ] , #NEWLINE# b'Content-Type' : [ b'multipart/form-data; boundary=heyDavid' ] , #NEWLINE# #UNINDENT# } ) , self . MultiPartProducer . return_value ) #NEWLINE# FP = self . FileBodyProducer . return_value #NEWLINE# self . assertEqual ( mock . call ( [ ( 'a' , 'b' ) , ( 'key' , 'val' ) , ( 'file1' , ( 'image.jpg' , 'image/jpeg' , FP ) ) , ( 'file2' , ( 'image.png' , 'image/png' , FP ) ) ] , boundary = b'heyDavid' ) , FP . MultiPartProducer . call_args )