@@ -294,7 +294,9 @@ def test_disconnect_silently_pass_if_alias_does_not_exist(self):
294294 def test_disconnect_does_not_close_client_used_by_another_alias (self ):
295295 client1 = connect (alias = "disconnect_reused_client_test_1" )
296296 client2 = connect (alias = "disconnect_reused_client_test_2" )
297+ client3 = connect (alias = "disconnect_reused_client_test_3" , maxPoolSize = 10 )
297298 assert client1 is client2
299+ assert client1 is not client3
298300 client1 .admin .command ("ping" )
299301 disconnect ("disconnect_reused_client_test_1" )
300302 # The client is not closed because the second alias still exists.
@@ -304,6 +306,14 @@ def test_disconnect_does_not_close_client_used_by_another_alias(self):
304306 if PYMONGO_VERSION >= (4 ,):
305307 with pytest .raises (InvalidOperation ):
306308 client2 .admin .command ("ping" )
309+ # 3rd client connected to the same cluster with different options
310+ # is not closed either.
311+ client3 .admin .command ("ping" )
312+ disconnect ("disconnect_reused_client_test_3" )
313+ # 3rd client is now closed:
314+ if PYMONGO_VERSION >= (4 ,):
315+ with pytest .raises (InvalidOperation ):
316+ client3 .admin .command ("ping" )
307317
308318 def test_disconnect_all (self ):
309319 connections = mongoengine .connection ._connections
0 commit comments