Skip to content

Commit b7aa005

Browse files
committed
Merge pull request mongodb#86 from ajdavis/master
Make master-slave connection unittests succeed more reliably
2 parents 34b9f9b + 94bbd7b commit b7aa005

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

test/test_master_slave_connection.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,11 @@ def test_database_names(self):
182182
self.assert_("pymongo_test_mike" in dbs)
183183

184184
def test_drop_database(self):
185-
# This test has been known to fail due to SERVER-2329
186185
self.assertRaises(TypeError, self.connection.drop_database, 5)
187186
self.assertRaises(TypeError, self.connection.drop_database, None)
188187

188+
raise SkipTest("This test often fails due to SERVER-2329")
189+
189190
self.connection.pymongo_test.test.save({"dummy": u"object"}, safe=True)
190191
dbs = self.connection.database_names()
191192
self.assert_("pymongo_test" in dbs)
@@ -330,6 +331,7 @@ def test_base_object(self):
330331
self.assertFalse(db.safe)
331332
self.assertEqual({}, db.get_lasterror_options())
332333
coll = db.test
334+
coll.drop()
333335
self.assertFalse(coll.slave_okay)
334336
self.assertTrue(bool(c.read_preference))
335337
self.assertFalse(coll.safe)
@@ -339,21 +341,22 @@ def test_base_object(self):
339341
self.assertTrue(bool(cursor._Cursor__read_preference))
340342

341343
c.safe = True
342-
c.set_lasterror_options(w=3, wtimeout=100)
344+
w = 1 + len(self.slaves)
345+
c.set_lasterror_options(w=w, wtimeout=100)
343346
self.assertFalse(c.slave_okay)
344347
self.assertTrue(bool(c.read_preference))
345348
self.assertTrue(c.safe)
346-
self.assertEqual({'w': 3, 'wtimeout': 100}, c.get_lasterror_options())
349+
self.assertEqual({'w': w, 'wtimeout': 100}, c.get_lasterror_options())
347350
db = c.test
348351
self.assertFalse(db.slave_okay)
349352
self.assertTrue(bool(c.read_preference))
350353
self.assertTrue(db.safe)
351-
self.assertEqual({'w': 3, 'wtimeout': 100}, db.get_lasterror_options())
354+
self.assertEqual({'w': w, 'wtimeout': 100}, db.get_lasterror_options())
352355
coll = db.test
353356
self.assertFalse(coll.slave_okay)
354357
self.assertTrue(bool(c.read_preference))
355358
self.assertTrue(coll.safe)
356-
self.assertEqual({'w': 3, 'wtimeout': 100},
359+
self.assertEqual({'w': w, 'wtimeout': 100},
357360
coll.get_lasterror_options())
358361
cursor = coll.find()
359362
self.assertFalse(cursor._Cursor__slave_okay)

0 commit comments

Comments
 (0)