Skip to content

Commit a965a61

Browse files
committed
coverage: test allow_asyncio(get_future_instance, ...)
1 parent 917b4fe commit a965a61

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/interop/test_adapter.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,23 @@ async def run_trio_asyncio_future(self, loop):
223223
async def test_trio_asyncio_future(self, loop):
224224
await allow_asyncio(self.run_trio_asyncio_future, loop)
225225

226+
def get_asyncio_future(self, loop, sth):
227+
async def set_result(future, sth):
228+
await asyncio.sleep(0.01)
229+
sth.flag |= 1
230+
future.set_result(4)
231+
232+
f = loop.create_future()
233+
loop.create_task(set_result(f, sth))
234+
return f
235+
236+
@pytest.mark.trio
237+
async def test_trio_asyncio_future_getter(self, loop):
238+
sth = SomeThing(loop)
239+
res = await allow_asyncio(self.get_asyncio_future, loop, sth)
240+
assert res == 4
241+
assert sth.flag == 1
242+
226243
async def run_trio_asyncio_adapted(self, loop):
227244
sth = SomeThing(loop)
228245
res = await sth.dly_asyncio_adapted()

0 commit comments

Comments
 (0)