[fix] solution/backend: conftest 를 되돌린다 — 테스트가 안 돈 건 DB 비밀번호 탓이었다
This commit is contained in:
parent
411a4e7d55
commit
a5b8701f8b
@ -5,13 +5,6 @@ import os
|
||||
|
||||
os.environ.setdefault("APP_ENV", "test")
|
||||
|
||||
|
||||
def pytest_configure(config):
|
||||
"""순수 단위 테스트(test_itinerary_prompt.py 등)는 DB 없이 실행될 수 있도록 표시한다."""
|
||||
args = " ".join(config.invocation_params.args)
|
||||
# test_itinerary_prompt.py 만 실행 중인지 확인
|
||||
config.SKIP_DB_SETUP = "test_itinerary_prompt.py" in args
|
||||
|
||||
import uuid
|
||||
|
||||
import pytest
|
||||
@ -63,19 +56,13 @@ async def _drop_test_db(*, recreate: bool):
|
||||
|
||||
|
||||
@pytest_asyncio.fixture(scope="session", autouse=True)
|
||||
async def _test_db_lifecycle(request):
|
||||
async def _test_db_lifecycle():
|
||||
"""테스트 세션 동안만 test DB 를 만들고, 끝나면 내린다.
|
||||
|
||||
매 세션 '깨끗한 새 DB'로 시작하므로 스키마 낡음(드리프트)이 원천 차단되고, 끝나면 남는 DB 도 없다.
|
||||
(테이블 구조는 db_engine 의 create_all 이 현재 모델 기준으로 채운다.)
|
||||
안전가드: 이름에 'test' 있는 DB 만 만들고/지운다(dev DB 보호).
|
||||
|
||||
순수 단위 테스트(DB 필요 없음)는 SKIP_DB_SETUP 플래그로 이 fixture 를 건너뛴다.
|
||||
"""
|
||||
if getattr(request.config, "SKIP_DB_SETUP", False):
|
||||
yield
|
||||
return
|
||||
|
||||
assert "test" in main_db_config.name, (
|
||||
f"비-test DB('{main_db_config.name}') 는 만들거나 지우지 않는다. APP_ENV=test 로 실행하세요."
|
||||
)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user