@@ -224,7 +224,8 @@ def iterate():
224224 self .assertRaises (TypeError , iterate )
225225
226226 def test_get_default_database (self ):
227- c = rs_or_single_client ("mongodb://%s/foo" % (client_context .pair , ),
227+ c = rs_or_single_client ("mongodb://%s:%d/foo" % (client_context .host ,
228+ client_context .port ),
228229 connect = False )
229230 self .assertEqual (Database (c , 'foo' ), c .get_default_database ())
230231 # Test that default doesn't override the URI value.
@@ -239,36 +240,42 @@ def test_get_default_database(self):
239240 self .assertEqual (ReadPreference .SECONDARY , db .read_preference )
240241 self .assertEqual (write_concern , db .write_concern )
241242
242- c = rs_or_single_client ("mongodb://%s/" % (client_context .pair , ),
243+ c = rs_or_single_client ("mongodb://%s:%d/" % (client_context .host ,
244+ client_context .port ),
243245 connect = False )
244246 self .assertEqual (Database (c , 'foo' ), c .get_default_database ('foo' ))
245247
246248 def test_get_default_database_error (self ):
247249 # URI with no database.
248- c = rs_or_single_client ("mongodb://%s/" % (client_context .pair , ),
250+ c = rs_or_single_client ("mongodb://%s:%d/" % (client_context .host ,
251+ client_context .port ),
249252 connect = False )
250253 self .assertRaises (ConfigurationError , c .get_default_database )
251254
252255 def test_get_default_database_with_authsource (self ):
253256 # Ensure we distinguish database name from authSource.
254- uri = "mongodb://%s/foo?authSource=src" % (client_context .pair , )
257+ uri = "mongodb://%s:%d/foo?authSource=src" % (
258+ client_context .host , client_context .port )
255259 c = rs_or_single_client (uri , connect = False )
256260 self .assertEqual (Database (c , 'foo' ), c .get_default_database ())
257261
258262 def test_get_database_default (self ):
259- c = rs_or_single_client ("mongodb://%s/foo" % (client_context .pair , ),
263+ c = rs_or_single_client ("mongodb://%s:%d/foo" % (client_context .host ,
264+ client_context .port ),
260265 connect = False )
261266 self .assertEqual (Database (c , 'foo' ), c .get_database ())
262267
263268 def test_get_database_default_error (self ):
264269 # URI with no database.
265- c = rs_or_single_client ("mongodb://%s/" % (client_context .pair , ),
270+ c = rs_or_single_client ("mongodb://%s:%d/" % (client_context .host ,
271+ client_context .port ),
266272 connect = False )
267273 self .assertRaises (ConfigurationError , c .get_database )
268274
269275 def test_get_database_default_with_authsource (self ):
270276 # Ensure we distinguish database name from authSource.
271- uri = "mongodb://%s/foo?authSource=src" % (client_context .pair , )
277+ uri = "mongodb://%s:%d/foo?authSource=src" % (
278+ client_context .host , client_context .port )
272279 c = rs_or_single_client (uri , connect = False )
273280 self .assertEqual (Database (c , 'foo' ), c .get_database ())
274281
@@ -365,9 +372,10 @@ def test_uri_codec_options(self):
365372 # Ensure codec options are passed in correctly
366373 uuid_representation_label = 'javaLegacy'
367374 unicode_decode_error_handler = 'ignore'
368- uri = ("mongodb://%s/foo?tz_aware=true&uuidrepresentation="
375+ uri = ("mongodb://%s:%d /foo?tz_aware=true&uuidrepresentation="
369376 "%s&unicode_decode_error_handler=%s" % (
370- client_context .pair ,
377+ client_context .host ,
378+ client_context .port ,
371379 uuid_representation_label ,
372380 unicode_decode_error_handler ))
373381 c = MongoClient (uri , connect = False )
@@ -1362,8 +1370,8 @@ def init(self, *args):
13621370 try :
13631371 ServerHeartbeatStartedEvent .__init__ = init
13641372 listener = HeartbeatStartedListener ()
1365- uri = "mongodb://%s/?heartbeatFrequencyMS=500" % (
1366- client_context .pair , )
1373+ uri = "mongodb://%s:%d /?heartbeatFrequencyMS=500" % (
1374+ client_context .host , client_context . port )
13671375 client = single_client (uri , event_listeners = [listener ])
13681376 wait_until (lambda : len (listener .results ) >= 2 ,
13691377 "record two ServerHeartbeatStartedEvents" )
0 commit comments