PYTHON-4866 Fix test_command_cursor_to_list_csot_applied (#1926)

This commit is contained in:
Shane Harvey 2024-10-14 15:06:42 -07:00 committed by GitHub
parent 3cc722e910
commit a911245bde
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 16 deletions

View File

@ -1412,12 +1412,11 @@ class TestCursor(AsyncIntegrationTest):
self.assertEqual(len(docs), 2)
async def test_to_list_csot_applied(self):
client = await self.async_single_client(timeoutMS=500)
client = await self.async_single_client(timeoutMS=500, w=1)
coll = client.pymongo.test
# Initialize the client with a larger timeout to help make test less flakey
with pymongo.timeout(10):
await client.admin.command("ping")
coll = client.pymongo.test
await coll.insert_many([{} for _ in range(5)])
await coll.insert_many([{} for _ in range(5)])
cursor = coll.find({"$where": delay(1)})
with self.assertRaises(PyMongoError) as ctx:
await cursor.to_list()
@ -1454,12 +1453,11 @@ class TestCursor(AsyncIntegrationTest):
@async_client_context.require_failCommand_blockConnection
async def test_command_cursor_to_list_csot_applied(self):
client = await self.async_single_client(timeoutMS=500)
client = await self.async_single_client(timeoutMS=500, w=1)
coll = client.pymongo.test
# Initialize the client with a larger timeout to help make test less flakey
with pymongo.timeout(10):
await client.admin.command("ping")
coll = client.pymongo.test
await coll.insert_many([{} for _ in range(5)])
await coll.insert_many([{} for _ in range(5)])
fail_command = {
"configureFailPoint": "failCommand",
"mode": {"times": 5},

View File

@ -1403,12 +1403,11 @@ class TestCursor(IntegrationTest):
self.assertEqual(len(docs), 2)
def test_to_list_csot_applied(self):
client = self.single_client(timeoutMS=500)
client = self.single_client(timeoutMS=500, w=1)
coll = client.pymongo.test
# Initialize the client with a larger timeout to help make test less flakey
with pymongo.timeout(10):
client.admin.command("ping")
coll = client.pymongo.test
coll.insert_many([{} for _ in range(5)])
coll.insert_many([{} for _ in range(5)])
cursor = coll.find({"$where": delay(1)})
with self.assertRaises(PyMongoError) as ctx:
cursor.to_list()
@ -1445,12 +1444,11 @@ class TestCursor(IntegrationTest):
@client_context.require_failCommand_blockConnection
def test_command_cursor_to_list_csot_applied(self):
client = self.single_client(timeoutMS=500)
client = self.single_client(timeoutMS=500, w=1)
coll = client.pymongo.test
# Initialize the client with a larger timeout to help make test less flakey
with pymongo.timeout(10):
client.admin.command("ping")
coll = client.pymongo.test
coll.insert_many([{} for _ in range(5)])
coll.insert_many([{} for _ in range(5)])
fail_command = {
"configureFailPoint": "failCommand",
"mode": {"times": 5},