diff --git a/test/high_availability/test_ha.py b/test/high_availability/test_ha.py index 5cfef45d1..860375076 100644 --- a/test/high_availability/test_ha.py +++ b/test/high_availability/test_ha.py @@ -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): diff --git a/test/test_gridfs.py b/test/test_gridfs.py index 521d6c9d8..a87538359 100644 --- a/test/test_gridfs.py +++ b/test/test_gridfs.py @@ -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