File tree Expand file tree Collapse file tree 2 files changed +9
-0
lines changed
Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -670,6 +670,11 @@ def __init__(
670670 # Normalize combined options.
671671 opts = _normalize_options (opts )
672672
673+ # Ensure directConnection was not True if there are multiple seeds.
674+ if len (seeds ) > 1 and opts .get ('directconnection' ):
675+ raise ConfigurationError (
676+ "Cannot specify multiple hosts with directConnection=true" )
677+
673678 # Username and password passed as kwargs override user info in URI.
674679 username = opts .get ("username" , username )
675680 password = opts .get ("password" , password )
Original file line number Diff line number Diff line change @@ -1572,6 +1572,10 @@ def test_direct_connection(self):
15721572 TOPOLOGY_TYPE .ReplicaSetWithPrimary ])
15731573 client .close ()
15741574
1575+ # directConnection=True, should error with multiple hosts as a list.
1576+ with self .assertRaises (ConfigurationError ):
1577+ MongoClient (['host1' , 'host2' ], directConnection = True )
1578+
15751579
15761580class TestExhaustCursor (IntegrationTest ):
15771581 """Test that clients properly handle errors from exhaust cursors."""
You can’t perform that action at this time.
0 commit comments