#NEWLINE# def test_socket_timeout( self ) : #NEWLINE# #INDENT# no_timeout = self . client #NEWLINE# timeout_sec = 1 #NEWLINE# timeout = rs_or_single_client ( socketTimeoutMS = ( 1000 * timeout_sec ) ) #NEWLINE# no_timeout . pymongo_test . drop_collection ( 'test' ) #NEWLINE# no_timeout . pymongo_test . test . insert_one ( { #NEWLINE# #INDENT# 'x' : 1 , #NEWLINE# #UNINDENT# } ) #NEWLINE# where_func = delay ( ( timeout_sec + 1 ) ) #NEWLINE# def get_x( db ) : #NEWLINE# #INDENT# doc = next ( db . test . find ( ) . where ( where_func ) ) #NEWLINE# return doc [ 'x' ] #NEWLINE# #UNINDENT# self . assertEqual ( 1 , get_x ( no_timeout . pymongo_test ) ) #NEWLINE# self . assertRaises ( NetworkTimeout , self , timeout . pymongo_test )