Skip to content

Commit

Permalink
Merge pull request #125 from slaarti/test_session_typing
Browse files Browse the repository at this point in the history
Fix return type for async session fixture in tests.
  • Loading branch information
igorbenav authored Jul 9, 2024
2 parents e70ffe5 + ef1a945 commit ef29727
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion tests/sqlalchemy/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from collections.abc import AsyncGenerator
from typing import Optional
from datetime import datetime

Expand Down Expand Up @@ -278,7 +279,7 @@ class TaskRead(TaskReadSub):


@pytest_asyncio.fixture(scope="function")
async def async_session() -> AsyncSession:
async def async_session() -> AsyncGenerator[AsyncSession]:
session = sessionmaker(async_engine, class_=AsyncSession, expire_on_commit=False)

async with session() as s:
Expand Down
3 changes: 2 additions & 1 deletion tests/sqlmodel/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from collections.abc import AsyncGenerator
from typing import Optional

import pytest
Expand Down Expand Up @@ -272,7 +273,7 @@ class TaskRead(TaskReadSub):


@pytest_asyncio.fixture(scope="function")
async def async_session() -> AsyncSession:
async def async_session() -> AsyncGenerator[AsyncSession]:
session = sessionmaker(async_engine, class_=AsyncSession, expire_on_commit=False)

async with session() as s:
Expand Down

0 comments on commit ef29727

Please sign in to comment.