Skip to content

Commit 53c88cc

Browse files
committed
fix typing
1 parent 45695db commit 53c88cc

File tree

2 files changed

+29
-23
lines changed

2 files changed

+29
-23
lines changed

test/asynchronous/test_retryable_writes.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"""Test retryable writes."""
1616
from __future__ import annotations
1717

18+
import asyncio
1819
import copy
1920
import pprint
2021
import sys
@@ -71,22 +72,24 @@
7172

7273

7374
class InsertEventListener(EventListener):
74-
async def succeeded(self, event: CommandSucceededEvent) -> None:
75+
def succeeded(self, event: CommandSucceededEvent) -> None:
7576
super().succeeded(event)
7677
if (
7778
event.command_name == "insert"
7879
and event.reply.get("writeConcernError", {}).get("code", None) == 91
7980
):
80-
await async_client_context.client.admin.command(
81-
{
82-
"configureFailPoint": "failCommand",
83-
"mode": {"times": 1},
84-
"data": {
85-
"errorCode": 10107,
86-
"errorLabels": ["RetryableWriteError", "NoWritesPerformed"],
87-
"failCommands": ["insert"],
88-
},
89-
}
81+
asyncio.run(
82+
async_client_context.client.admin.command(
83+
{
84+
"configureFailPoint": "failCommand",
85+
"mode": {"times": 1},
86+
"data": {
87+
"errorCode": 10107,
88+
"errorLabels": ["RetryableWriteError", "NoWritesPerformed"],
89+
"failCommands": ["insert"],
90+
},
91+
}
92+
)
9093
)
9194

9295

@@ -372,7 +375,7 @@ async def test_batch_splitting(self):
372375
# With OP_MSG 3 inserts are one batch. 2 updates another.
373376
# 2 deletes a third.
374377
self.assertEqual(len(self.listener.started_events), 6)
375-
await self.assertEqual(coll.find_one(), {"_id": 1, "count": 1})
378+
self.assertEqual(await coll.find_one(), {"_id": 1, "count": 1})
376379
# Assert the final result
377380
expected_result = {
378381
"writeErrors": [],
@@ -434,7 +437,7 @@ async def test_batch_splitting_retry_fails(self):
434437
self.assertEqual(started[1].command, started[2].command)
435438
final_txn = session._transaction_id
436439
self.assertEqual(final_txn, expected_txn)
437-
await self.assertEqual(coll.find_one(projection={"_id": True}), {"_id": 1})
440+
self.assertEqual(await coll.find_one(projection={"_id": True}), {"_id": 1})
438441

439442
@async_client_context.require_multiple_mongoses
440443
@async_client_context.require_failCommand_fail_point

test/test_retryable_writes.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"""Test retryable writes."""
1616
from __future__ import annotations
1717

18+
import asyncio
1819
import copy
1920
import pprint
2021
import sys
@@ -77,16 +78,18 @@ def succeeded(self, event: CommandSucceededEvent) -> None:
7778
event.command_name == "insert"
7879
and event.reply.get("writeConcernError", {}).get("code", None) == 91
7980
):
80-
client_context.client.admin.command(
81-
{
82-
"configureFailPoint": "failCommand",
83-
"mode": {"times": 1},
84-
"data": {
85-
"errorCode": 10107,
86-
"errorLabels": ["RetryableWriteError", "NoWritesPerformed"],
87-
"failCommands": ["insert"],
88-
},
89-
}
81+
asyncio.run(
82+
client_context.client.admin.command(
83+
{
84+
"configureFailPoint": "failCommand",
85+
"mode": {"times": 1},
86+
"data": {
87+
"errorCode": 10107,
88+
"errorLabels": ["RetryableWriteError", "NoWritesPerformed"],
89+
"failCommands": ["insert"],
90+
},
91+
}
92+
)
9093
)
9194

9295

0 commit comments

Comments
 (0)