#NEWLINE# def test_multi_status_codes( self ) : #NEWLINE# #INDENT# m = pycurl . CurlMulti ( ) #NEWLINE# m . handles = [ ] #NEWLINE# urls = [ 'http://localhost:8380/success' , 'http://localhost:8381/status/403' , 'http://localhost:8382/status/404' ] #NEWLINE# for url in urls : #NEWLINE# #INDENT# c = pycurl . Curl ( ) #NEWLINE# c . url = url . rstrip ( ) #NEWLINE# c . body = util . StringIO ( ) #NEWLINE# c . http_code = ( - 1 ) #NEWLINE# m . handles . append ( c ) #NEWLINE# c . setopt ( url . URL , c . url ) #NEWLINE# c . setopt ( c . WRITEFUNCTION , c . body . write ) #NEWLINE# m . add_handle ( c ) #NEWLINE# #UNINDENT# num_handles = len ( m . handles ) #NEWLINE# while num_handles : #NEWLINE# #INDENT# while 1 : #NEWLINE# #INDENT# ( ret , num_handles ) = m . perform ( ) #NEWLINE# if ( ret != pycurl . E_CALL_MULTI_PERFORM ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# #UNINDENT# m . select ( 0.1 ) #NEWLINE# #UNINDENT# for c in m . handles : #NEWLINE# #INDENT# c . http_code = c . getinfo ( c . HTTP_CODE ) #NEWLINE# m . remove_handle ( c ) #NEWLINE# c . close ( ) #NEWLINE# #UNINDENT# m . close ( ) #NEWLINE# self . assertEqual ( 'success' , m . handles [ 0 ] . body . getvalue ( ) ) #NEWLINE# self . assertEqual ( 200 , m . handles [ 0 ] . http_code ) #NEWLINE# self . assertEqual ( 'forbidden' , m . handles [ 1 ] . body . getvalue ( ) ) #NEWLINE# self . assertEqual ( 403 , m . handles [ 1 ] . http_code ) #NEWLINE# self . assertEqual ( 'not found' , m . handles [ 2 ] . body . getvalue ( ) ) #NEWLINE# self . assertEqual ( 404 , m . handles [ 2 ] . http_code )