#NEWLINE# def test_content_length( self ) : #NEWLINE# #INDENT# con = Connection ( ) #NEWLINE# con . connection = Mock ( ) #NEWLINE# con . request ( '/test' , method = 'GET' , data = None ) #NEWLINE# call_kwargs = con . connection . request . call_args [ 1 ] #NEWLINE# self . assertTrue ( ( 'Content-Length' not in call_kwargs [ 'headers' ] ) ) #NEWLINE# con . request ( '/test' , method = 'GET' , data = '' ) #NEWLINE# call_kwargs = con . connection . request . call_args [ 1 ] #NEWLINE# self . assertTrue ( ( 'Content-Length' not in call_kwargs [ 'headers' ] ) ) #NEWLINE# con . request ( '/test' , method = 'GET' , data = 'a' ) #NEWLINE# call_kwargs = con . connection . request . call_args [ 1 ] #NEWLINE# self . assertEqual ( call_kwargs [ 'headers' ] [ 'Content-Length' ] , '1' ) #NEWLINE# for method in [ 'POST' , 'PUT' , 'post' , 'put' ] : #NEWLINE# #INDENT# con . request ( '/test' , method = method , data = None ) #NEWLINE# call_kwargs = con . connection . request . call_args [ 1 ] #NEWLINE# self . assertEqual ( con [ 'headers' ] [ 'Content-Length' ] , '0' ) #NEWLINE# #UNINDENT# for method in [ 'POST' , 'PUT' , 'post' , 'put' ] : #NEWLINE# #INDENT# con . request ( '/test' , method = method , data = '' ) #NEWLINE# call_kwargs = con . connection . request . call_args [ 1 ] #NEWLINE# self . assertEqual ( call_kwargs [ 'headers' ] [ 'Content-Length' ] , '0' ) #NEWLINE# #UNINDENT# for method in [ 'POST' , 'PUT' , 'post' , 'put' ] : #NEWLINE# #INDENT# con . request ( '/test' , method = method , data = None , headers = { #NEWLINE# #INDENT# 'Content-Length' : '42' , #NEWLINE# #UNINDENT# } , raw = True ) #NEWLINE# putheader_call_list = con . connection . putheader . call_args_list #NEWLINE# self . assertIn ( call ( 'Content-Length' , '42' ) , putheader_call_list ) #NEWLINE# #UNINDENT# for method in [ 'POST' , 'PUT' , 'post' , 'put' ] : #NEWLINE# #INDENT# con . request ( '/test' , method = method , data = None , headers = { #NEWLINE# #INDENT# 'Content-Length' : '42' , #NEWLINE# #UNINDENT# } , raw = True ) #NEWLINE# putheader_call_list = con . connection . putheader . call_args_list #NEWLINE# self . assertIn ( call ( 'Content-Length' , '42' ) , putheader_call_list ) #NEWLINE# #UNINDENT# for method in [ 'POST' , 'PUT' , 'post' , 'put' ] : #NEWLINE# #INDENT# con . request ( '/test' , method = method , data = 'a' ) #NEWLINE# call_kwargs = con . connection . request . call_args [ 1 ] #NEWLINE# self . assertEqual ( call_kwargs [ 'headers' ] [ 'Content-Length' ] , '1' )