Skip to content

Commit cf4d171

Browse files
committed
add test
1 parent 6686557 commit cf4d171

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

test/asynchronous/test_transactions.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"""Execute Transactions Spec tests."""
1616
from __future__ import annotations
1717

18+
import asyncio
1819
import sys
1920
from io import BytesIO
2021
from test.asynchronous.utils_spec_runner import AsyncSpecRunner
@@ -468,6 +469,17 @@ async def callback2(session):
468469
async with self.client.start_session() as s:
469470
self.assertEqual(await s.with_transaction(callback2), "Foo")
470471

472+
@async_client_context.require_transactions
473+
@async_client_context.require_async
474+
async def test_callback_awaitable_no_coroutine(self):
475+
def callback(_):
476+
future = asyncio.Future()
477+
future.set_result("Foo")
478+
return future
479+
480+
async with self.client.start_session() as s:
481+
self.assertEqual(await s.with_transaction(callback), "Foo")
482+
471483
@async_client_context.require_transactions
472484
async def test_callback_not_retried_after_timeout(self):
473485
listener = OvertCommandListener()

test/test_transactions.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"""Execute Transactions Spec tests."""
1616
from __future__ import annotations
1717

18+
import asyncio
1819
import sys
1920
from io import BytesIO
2021
from test.utils_spec_runner import SpecRunner
@@ -460,6 +461,17 @@ def callback2(session):
460461
with self.client.start_session() as s:
461462
self.assertEqual(s.with_transaction(callback2), "Foo")
462463

464+
@client_context.require_transactions
465+
@client_context.require_async
466+
def test_callback_awaitable_no_coroutine(self):
467+
def callback(_):
468+
future = asyncio.Future()
469+
future.set_result("Foo")
470+
return future
471+
472+
with self.client.start_session() as s:
473+
self.assertEqual(s.with_transaction(callback), "Foo")
474+
463475
@client_context.require_transactions
464476
def test_callback_not_retried_after_timeout(self):
465477
listener = OvertCommandListener()

0 commit comments

Comments
 (0)