Skip to content

Commit 180228e

Browse files
committed
tests: replace pytest-asyncio with anyio
1 parent 6404d7d commit 180228e

File tree

5 files changed

+12
-21
lines changed

5 files changed

+12
-21
lines changed

pyproject.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,13 @@ dependencies = [
1111
"mkdoc>=0.1",
1212
"mkdocs-material>=9.5.48",
1313
"pytest>=8.3.4",
14-
"pytest-asyncio>=0.24.0",
1514
"ruff>=0.8.2",
1615
"sqlalchemy>=2.0.36",
1716
"testcontainers>=4.8.2",
1817
]
1918

2019
[tool.pytest.ini_options]
2120
pythonpath = '.'
22-
asyncio_mode = 'auto'
2321

2422
[tool.ruff]
2523
line-length = 79

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ aiosqlite>=0.20.0
22
asyncpg>=0.30.0
33
fastapi[standard]>=0.115.6
44
pytest>=8.3.4
5-
pytest-asyncio>=0.24.0
65
ruff>=0.8.2
76
sqlalchemy>=2.0.36
87
testcontainers>=4.8.2

tests/conftest.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import pytest_asyncio
1+
import pytest
22
from httpx import ASGITransport, AsyncClient
33
from sqlalchemy.ext.asyncio import (
44
AsyncSession,
@@ -12,13 +12,18 @@
1212
from src.models import table_register
1313

1414

15-
@pytest_asyncio.fixture(scope='session')
15+
@pytest.fixture
16+
def anyio_backend():
17+
return 'asyncio'
18+
19+
20+
@pytest.fixture(scope='session')
1621
def postgres_container():
1722
with PostgresContainer('postgres:16', driver='asyncpg') as postgres:
1823
yield postgres
1924

2025

21-
@pytest_asyncio.fixture
26+
@pytest.fixture
2227
async def async_session(postgres_container: PostgresContainer):
2328
async_db_url = postgres_container.get_connection_url()
2429
async_engine = create_async_engine(async_db_url, pool_pre_ping=True)
@@ -40,7 +45,7 @@ async def async_session(postgres_container: PostgresContainer):
4045
await async_engine.dispose()
4146

4247

43-
@pytest_asyncio.fixture
48+
@pytest.fixture
4449
async def async_client(async_session: async_sessionmaker[AsyncSession]):
4550
app.dependency_overrides[get_session] = lambda: async_session
4651
_transport = ASGITransport(app=app)

tests/test_routes.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
from http import HTTPStatus
22

3+
import pytest
34
from httpx import AsyncClient
45
from sqlalchemy.ext.asyncio import AsyncSession
56

67
from src.models import Ticket
78

9+
pytestmark = pytest.mark.anyio
10+
811

912
async def test_get_all_tickets_success(
1013
async_session: AsyncSession, async_client: AsyncClient

uv.lock

Lines changed: 0 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)