Skip to content

Commit 7b0c03f

Browse files
committed
refactor: clean up imports and improve db_session fixture in test configuration
1 parent a24c47a commit 7b0c03f

3 files changed

Lines changed: 4 additions & 5 deletions

File tree

app/config.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ def test_asyncpg_url(self) -> PostgresDsn:
106106
path=self.POSTGRES_TEST_DB,
107107
)
108108

109-
110109
@computed_field
111110
@property
112111
def postgres_url(self) -> PostgresDsn:

app/database.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,4 @@ async def get_test_db() -> AsyncGenerator:
6464
# Only log actual database-related issues, not response validation
6565
if not isinstance(ex, ResponseValidationError):
6666
await logger.aerror(f"Database-related error: {repr(ex)}")
67-
raise # Re-raise to be handled by appropriate handlers
67+
raise # Re-raise to be handled by appropriate handlers

tests/conftest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from collections.abc import AsyncGenerator
2-
from types import SimpleNamespace
32
from typing import Any
43

54
import pytest
@@ -8,7 +7,7 @@
87
from sqlalchemy.exc import ProgrammingError
98
from sqlalchemy.ext.asyncio import AsyncSession
109

11-
from app.database import engine, test_engine, get_test_db, get_db
10+
from app.database import engine, get_db, test_engine
1211
from app.main import app
1312
from app.models.base import Base
1413
from app.redis import get_redis
@@ -23,6 +22,7 @@
2322
def anyio_backend(request):
2423
return request.param
2524

25+
2626
def _create_db(conn) -> None:
2727
"""Create the test database if it doesn't exist."""
2828
try:
@@ -66,7 +66,7 @@ async def start_db():
6666

6767

6868
@pytest.fixture(scope="function")
69-
async def db_session(start_db) -> AsyncGenerator[AsyncSession, Any]:
69+
async def db_session() -> AsyncGenerator[AsyncSession, Any]:
7070
"""
7171
Provide a transactional database session for each test function.
7272
Rolls back changes after the test.

0 commit comments

Comments
 (0)