Skip to content

Commit a911245

Browse files
authored
PYTHON-4866 Fix test_command_cursor_to_list_csot_applied (mongodb#1926)
1 parent 3cc722e commit a911245

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

test/asynchronous/test_cursor.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1412,12 +1412,11 @@ async def test_to_list_length(self):
14121412
self.assertEqual(len(docs), 2)
14131413

14141414
async def test_to_list_csot_applied(self):
1415-
client = await self.async_single_client(timeoutMS=500)
1415+
client = await self.async_single_client(timeoutMS=500, w=1)
1416+
coll = client.pymongo.test
14161417
# Initialize the client with a larger timeout to help make test less flakey
14171418
with pymongo.timeout(10):
1418-
await client.admin.command("ping")
1419-
coll = client.pymongo.test
1420-
await coll.insert_many([{} for _ in range(5)])
1419+
await coll.insert_many([{} for _ in range(5)])
14211420
cursor = coll.find({"$where": delay(1)})
14221421
with self.assertRaises(PyMongoError) as ctx:
14231422
await cursor.to_list()
@@ -1454,12 +1453,11 @@ async def test_command_cursor_to_list_length(self):
14541453

14551454
@async_client_context.require_failCommand_blockConnection
14561455
async def test_command_cursor_to_list_csot_applied(self):
1457-
client = await self.async_single_client(timeoutMS=500)
1456+
client = await self.async_single_client(timeoutMS=500, w=1)
1457+
coll = client.pymongo.test
14581458
# Initialize the client with a larger timeout to help make test less flakey
14591459
with pymongo.timeout(10):
1460-
await client.admin.command("ping")
1461-
coll = client.pymongo.test
1462-
await coll.insert_many([{} for _ in range(5)])
1460+
await coll.insert_many([{} for _ in range(5)])
14631461
fail_command = {
14641462
"configureFailPoint": "failCommand",
14651463
"mode": {"times": 5},

test/test_cursor.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,12 +1403,11 @@ def test_to_list_length(self):
14031403
self.assertEqual(len(docs), 2)
14041404

14051405
def test_to_list_csot_applied(self):
1406-
client = self.single_client(timeoutMS=500)
1406+
client = self.single_client(timeoutMS=500, w=1)
1407+
coll = client.pymongo.test
14071408
# Initialize the client with a larger timeout to help make test less flakey
14081409
with pymongo.timeout(10):
1409-
client.admin.command("ping")
1410-
coll = client.pymongo.test
1411-
coll.insert_many([{} for _ in range(5)])
1410+
coll.insert_many([{} for _ in range(5)])
14121411
cursor = coll.find({"$where": delay(1)})
14131412
with self.assertRaises(PyMongoError) as ctx:
14141413
cursor.to_list()
@@ -1445,12 +1444,11 @@ def test_command_cursor_to_list_length(self):
14451444

14461445
@client_context.require_failCommand_blockConnection
14471446
def test_command_cursor_to_list_csot_applied(self):
1448-
client = self.single_client(timeoutMS=500)
1447+
client = self.single_client(timeoutMS=500, w=1)
1448+
coll = client.pymongo.test
14491449
# Initialize the client with a larger timeout to help make test less flakey
14501450
with pymongo.timeout(10):
1451-
client.admin.command("ping")
1452-
coll = client.pymongo.test
1453-
coll.insert_many([{} for _ in range(5)])
1451+
coll.insert_many([{} for _ in range(5)])
14541452
fail_command = {
14551453
"configureFailPoint": "failCommand",
14561454
"mode": {"times": 5},

0 commit comments

Comments
 (0)