File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -305,7 +305,9 @@ def _parse_uri(self, scheme='mongodb://'):
305305
306306 port = client .port if client .port else self .default_port
307307
308- parsed = uri_parser .parse_uri (hostname , port )
308+ # We disable validating and normalization parameters here,
309+ # because pymongo will validate and normalize parameters later in __init__ of MongoClient
310+ parsed = uri_parser .parse_uri (hostname , port , validate = False )
309311
310312 dbname = parsed ['database' ] or client .virtual_host
311313
Original file line number Diff line number Diff line change @@ -116,6 +116,18 @@ def test_correct_readpreference(self):
116116 hostname , dbname , options = channel ._parse_uri ()
117117 assert options ['readpreference' ] == 'nearest'
118118
119+ def test_normalizes_params_from_uri_only_once (self ):
120+ channel = _create_mock_connection ('mongodb://localhost/?serverselectiontimeoutms=1000' ).default_channel
121+
122+ def server_info (self ):
123+ return {'version' : '3.6.0-rc' }
124+
125+ with patch .object (pymongo .MongoClient , 'server_info' , server_info ):
126+ database = channel ._open ()
127+
128+ client_options = database .client .options
129+ assert client_options .server_selection_timeout == 1.0
130+
119131
120132class BaseMongoDBChannelCase :
121133
You can’t perform that action at this time.
0 commit comments