Move shared test stuff into conftest.py

This commit is contained in:
Campbell Alden 2026-09-03 23:11:47 +09:00
parent acb343f559
commit da40febc7f
2 changed files with 7 additions and 6 deletions

View file

@ -1,3 +1,4 @@
import pytest
from src.infra import Base
from sqlalchemy import Engine, create_engine
@ -6,3 +7,8 @@ def mock_db() -> Engine:
engine = create_engine('sqlite:///:memory:', echo=True)
Base.metadata.create_all(engine)
return engine
@pytest.fixture
def db():
return mock_db()

View file

@ -2,15 +2,10 @@ from src.utils.secret import SecretBox
from src.services.users.data import UserDTO, User
from src.services.users.repo import UserRepo
from src.infra.users import UserRepoImpl
from src.infra.db_test import mock_db
import pytest
@pytest.fixture
def db():
return mock_db()
@pytest.fixture
def repo(db):
return UserRepoImpl(db)