File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -382,14 +382,19 @@ def test_auto_reconnect_exception_when_read_preference_is_secondary(self):
382382 def raise_socket_error (* args , ** kwargs ):
383383 raise socket .error
384384
385- old_sendall = socket .socket .sendall
386- socket .socket .sendall = raise_socket_error
385+ # In Jython 2.7 socket.socket is a function, not a class.
386+ sock = socket .socket ()
387+ klass = sock .__class__
388+ old_sendall = klass .sendall
389+ klass .sendall = raise_socket_error
387390
388391 try :
389392 cursor = db .test .find (read_preference = ReadPreference .SECONDARY )
390393 self .assertRaises (AutoReconnect , cursor .next )
391394 finally :
392- socket .socket .sendall = old_sendall
395+ klass .sendall = old_sendall
396+ # Silence resource warnings.
397+ sock .close ()
393398
394399 def test_operations (self ):
395400 c = self ._get_client ()
You can’t perform that action at this time.
0 commit comments