Skip to content

Commit 301cef5

Browse files
committed
imported trio-asyncio tests from pytest-trio
1 parent 21c5916 commit 301cef5

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

tests/test_trio_asyncio.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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()

0 commit comments

Comments
 (0)