PYTHON-1235 - Fix auto reconnect test under Jython

This commit is contained in:
Bernie Hackett 2017-02-01 12:25:31 -08:00 committed by Bernie Hackett
parent 033dcf1b08
commit aa5249068a

View File

@ -172,15 +172,20 @@ class TestReplicaSetClient(TestReplicaSetClientBase):
def raise_socket_error(*args, **kwargs):
raise socket.error
old_sendall = socket.socket.sendall
socket.socket.sendall = raise_socket_error
# In Jython socket.socket is a function, not a class.
sock = socket.socket()
klass = sock.__class__
old_sendall = klass.sendall
klass.sendall = raise_socket_error
try:
cursor = db.get_collection(
"test", read_preference=ReadPreference.SECONDARY).find()
self.assertRaises(AutoReconnect, cursor.next)
finally:
socket.socket.sendall = old_sendall
klass.sendall = old_sendall
# Silence resource warnings.
sock.close()
@client_context.require_secondaries_count(1)
def test_timeout_does_not_mark_member_down(self):