No more need to call MongoClient.close in tests.

This commit is contained in:
A. Jesse Jiryu Davis 2015-01-22 21:33:33 -05:00
parent 6cd00eee7f
commit 565e5faeb9
2 changed files with 19 additions and 25 deletions

View File

@ -787,26 +787,23 @@ class TestAlive(HATestCase):
secondary_cx = connected(MongoClient(secondary))
rsc = connected(MongoClient(self.seed, replicaSet=self.name))
try:
self.assertTrue(primary_cx.alive())
self.assertTrue(secondary_cx.alive())
self.assertTrue(rsc.alive())
ha_tools.kill_primary()
time.sleep(0.5)
self.assertTrue(primary_cx.alive())
self.assertTrue(secondary_cx.alive())
self.assertTrue(rsc.alive())
self.assertFalse(primary_cx.alive())
self.assertTrue(secondary_cx.alive())
self.assertFalse(rsc.alive())
ha_tools.kill_members([secondary], 2)
time.sleep(0.5)
ha_tools.kill_primary()
time.sleep(0.5)
self.assertFalse(primary_cx.alive())
self.assertFalse(secondary_cx.alive())
self.assertFalse(rsc.alive())
finally:
rsc.close()
self.assertFalse(primary_cx.alive())
self.assertTrue(secondary_cx.alive())
self.assertFalse(rsc.alive())
ha_tools.kill_members([secondary], 2)
time.sleep(0.5)
self.assertFalse(primary_cx.alive())
self.assertFalse(secondary_cx.alive())
self.assertFalse(rsc.alive())
class TestMongosHighAvailability(HATestCase):

View File

@ -446,13 +446,10 @@ class TestGridfsReplicaSet(TestReplicaSetClientBase):
w=self.w, wtimeout=5000,
read_preference=ReadPreference.SECONDARY)
try:
fs = gridfs.GridFS(rsc.pymongo_test)
oid = fs.put(b'foo')
content = fs.get(oid).read()
self.assertEqual(b'foo', content)
finally:
rsc.close()
fs = gridfs.GridFS(rsc.pymongo_test)
oid = fs.put(b'foo')
content = fs.get(oid).read()
self.assertEqual(b'foo', content)
def test_gridfs_secondary(self):
primary_host, primary_port = self.primary