@@ -175,10 +175,9 @@ def test_gssapi_threaded(self):
175175
176176 set_name = client .admin .command ('ismaster' ).get ('setName' )
177177 if set_name :
178- preference = ReadPreference .SECONDARY
179178 client = MongoClient (GSSAPI_HOST ,
180179 replicaSet = set_name ,
181- read_preference = preference )
180+ readPreference = 'secondary' )
182181 self .assertTrue (client .test .authenticate (PRINCIPAL ,
183182 mechanism = 'GSSAPI' ))
184183 self .assertTrue (client .test .command ('dbstats' ))
@@ -308,8 +307,9 @@ def test_scram_sha1(self):
308307 '&replicaSet=%s' % (host , port , self .replica_set_name ))
309308 client = MongoClient (uri )
310309 client .pymongo_test .command ('dbstats' )
311- client .read_preference = ReadPreference .SECONDARY
312- client .pymongo_test .command ('dbstats' )
310+ db = client .get_database (
311+ 'pymongo_test' , read_preference = ReadPreference .SECONDARY )
312+ db .command ('dbstats' )
313313
314314 def tearDown (self ):
315315 client_context .rs_or_standalone_client .pymongo_test .remove_user ('user' )
@@ -357,8 +357,9 @@ def test_uri_options(self):
357357 '@%s:%d/?replicaSet=%s' % (host , port , self .replica_set_name ))
358358 client = MongoClient (uri )
359359 self .assertTrue (client .admin .command ('dbstats' ))
360- client .read_preference = ReadPreference .SECONDARY
361- self .assertTrue (client .admin .command ('dbstats' ))
360+ db = client .get_database (
361+ 'admin' , read_preference = ReadPreference .SECONDARY )
362+ self .assertTrue (db .command ('dbstats' ))
362363
363364 # Test explicit database
364365 uri = 'mongodb://user:pass@%s:%d/pymongo_test' % (host , port )
@@ -373,8 +374,9 @@ def test_uri_options(self):
373374 self .assertRaises (OperationFailure ,
374375 client .admin .command , 'dbstats' )
375376 self .assertTrue (client .pymongo_test .command ('dbstats' ))
376- client .read_preference = ReadPreference .SECONDARY
377- self .assertTrue (client .pymongo_test .command ('dbstats' ))
377+ db = client .get_database (
378+ 'pymongo_test' , read_preference = ReadPreference .SECONDARY )
379+ self .assertTrue (db .command ('dbstats' ))
378380
379381 # Test authSource
380382 uri = ('mongodb://user:pass@%s:%d'
@@ -391,8 +393,9 @@ def test_uri_options(self):
391393 self .assertRaises (OperationFailure ,
392394 client .pymongo_test2 .command , 'dbstats' )
393395 self .assertTrue (client .pymongo_test .command ('dbstats' ))
394- client .read_preference = ReadPreference .SECONDARY
395- self .assertTrue (client .pymongo_test .command ('dbstats' ))
396+ db = client .get_database (
397+ 'pymongo_test' , read_preference = ReadPreference .SECONDARY )
398+ self .assertTrue (db .command ('dbstats' ))
396399
397400
398401class TestDelegatedAuth (unittest .TestCase ):
0 commit comments