File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import pytest
2+ import sys
3+ import asyncio
4+ from async_generator import async_generator , yield_
5+ import trio_asyncio
6+
7+
8+ async def use_asyncio ():
9+ await trio_asyncio .aio_as_trio (asyncio .sleep )(0 )
10+
11+
12+ @pytest .fixture ()
13+ @async_generator
14+ async def asyncio_loop ():
15+ async with trio_asyncio .open_loop () as loop :
16+ await yield_ (loop )
17+
18+
19+ @pytest .fixture ()
20+ @async_generator
21+ async def asyncio_fixture_with_fixtured_loop (asyncio_loop ):
22+ await use_asyncio ()
23+ await yield_ ()
24+
25+
26+ @pytest .fixture ()
27+ @async_generator
28+ async def asyncio_fixture_own_loop ():
29+ async with trio_asyncio .open_loop ():
30+ await use_asyncio ()
31+ await yield_ ()
32+
33+
34+ @pytest .mark .trio
35+ async def test_no_fixture ():
36+ async with trio_asyncio .open_loop ():
37+ await use_asyncio ()
38+
39+
40+ @pytest .mark .trio
41+ async def test_half_fixtured_asyncpg_conn (asyncio_fixture_own_loop ):
42+ await use_asyncio ()
43+
44+
45+ @pytest .mark .trio
46+ async def test_fixtured_asyncpg_conn (asyncio_fixture_with_fixtured_loop ):
47+ await use_asyncio ()
You can’t perform that action at this time.
0 commit comments