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__(
670
670
# Normalize combined options.
671
671
opts = _normalize_options (opts )
672
672
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
+
673
678
# Username and password passed as kwargs override user info in URI.
674
679
username = opts .get ("username" , username )
675
680
password = opts .get ("password" , password )
Original file line number Diff line number Diff line change @@ -1572,6 +1572,10 @@ def test_direct_connection(self):
1572
1572
TOPOLOGY_TYPE .ReplicaSetWithPrimary ])
1573
1573
client .close ()
1574
1574
1575
+ # directConnection=True, should error with multiple hosts as a list.
1576
+ with self .assertRaises (ConfigurationError ):
1577
+ MongoClient (['host1' , 'host2' ], directConnection = True )
1578
+
1575
1579
1576
1580
class TestExhaustCursor (IntegrationTest ):
1577
1581
"""Test that clients properly handle errors from exhaust cursors."""
You can’t perform that action at this time.
0 commit comments