Skip to content

Commit fc0ce0d

Browse files
committed
Fix skiptest issue.
1 parent afe49a4 commit fc0ce0d

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

test/test_common.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
sys.path[0:0] = [""]
2323

24+
from nose.plugins.skip import SkipTest
25+
2426
from bson.objectid import ObjectId
2527
from bson.son import SON
2628
from pymongo.connection import Connection
@@ -305,8 +307,9 @@ def test_mongo_client(self):
305307
def test_replica_set_connection(self):
306308
c = Connection(pair)
307309
ismaster = c.admin.command('ismaster')
308-
setname = str(ismaster.get('setName'))
309-
if not setname:
310+
if 'setName' in ismaster:
311+
setname = str(ismaster.get('setName'))
312+
else:
310313
raise SkipTest("Not connected to a replica set.")
311314
c = ReplicaSetConnection(pair, replicaSet=setname)
312315
coll = c.pymongo_test.write_concern_test
@@ -339,8 +342,9 @@ def test_replica_set_connection(self):
339342
def test_mongo_replica_set_client(self):
340343
c = Connection(pair)
341344
ismaster = c.admin.command('ismaster')
342-
setname = str(ismaster.get('setName'))
343-
if not setname:
345+
if 'setName' in ismaster:
346+
setname = str(ismaster.get('setName'))
347+
else:
344348
raise SkipTest("Not connected to a replica set.")
345349
m = MongoReplicaSetClient(pair, replicaSet=setname, w=0)
346350
coll = m.pymongo_test.write_concern_test

0 commit comments

Comments
 (0)