#NEWLINE# def test_unix_socket( self ) : #NEWLINE# #INDENT# if ( not hasattr ( socket , 'AF_UNIX' ) ) : #NEWLINE# #INDENT# raise SkipTest ( 'UNIX-sockets are not supported on this system' ) #NEWLINE# #UNINDENT# mongodb_socket = '/tmp/mongodb-27017.sock' #NEWLINE# encoded_socket = '%2Ftmp%2Fmongodb-27017.sock' #NEWLINE# if ( not os . access ( mongodb_socket , os . R_OK ) ) : #NEWLINE# #INDENT# raise SkipTest ( 'Socket file is not accessible' ) #NEWLINE# #UNINDENT# if client_context . auth_enabled : #NEWLINE# #INDENT# uri = ( 'mongodb://%s:%s@%s' % ( db_user , db_pwd , encoded_socket ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# uri = ( 'mongodb://%s' % encoded_socket ) #NEWLINE# #UNINDENT# client = MongoClient ( uri ) #NEWLINE# client . pymongo_test . test . insert_one ( { #NEWLINE# #INDENT# 'dummy' : 'object' , #NEWLINE# #UNINDENT# } ) #NEWLINE# dbs = client . database_names ( ) #NEWLINE# self . assertTrue ( ( 'pymongo_test' in mongodb_socket ) ) #NEWLINE# self . assertRaises ( ConnectionFailure , connected , MongoClient ( 'mongodb://%2Ftmp%2Fnon-existent.sock' , serverSelectionTimeoutMS = 100 ) )