# 테스트 실행을 위한 설치 가이드 ## 필요한 패키지 설치 ### 1. Poetry를 사용하는 경우 ```bash # 모든 의존성 설치 poetry install # 테스트 관련 패키지 추가 설치 (필요시) poetry add --group dev pytest-cov pytest-asyncio ``` ### 2. pip를 사용하는 경우 ```bash # requirements.txt 생성 poetry export -f requirements.txt --output requirements.txt --without-hashes # pip로 설치 pip install -r requirements.txt # 테스트 관련 패키지 추가 pip install pytest pytest-cov pytest-asyncio ``` ### 3. python-jose 관련 문제 해결 ```bash # python-jose가 설치되어 있는지 확인 poetry show python-jose # 없다면 설치 poetry add python-jose[cryptography] # 또는 pip로 pip install python-jose[cryptography] ``` ## 일반적인 문제 해결 ### ImportError 해결 1. PYTHONPATH 설정 ```bash export PYTHONPATH=$PYTHONPATH:/home/jhpark/workspace/O2Sound_ver2/backend ``` 2. 가상환경 확인 ```bash # Poetry 가상환경 활성화 poetry shell # 또는 직접 실행 poetry run pytest tests/ ``` ### 모델 관련 에러 - `UserItem` → `Item` - `UserVideo` → `Video` - 실제 모델 이름과 테스트 코드의 import를 확인하세요. ## 테스트 실행 전 체크리스트 1. ✅ 가상환경이 활성화되어 있는가? 2. ✅ 모든 의존성이 설치되어 있는가? 3. ✅ PYTHONPATH가 올바르게 설정되어 있는가? 4. ✅ 데이터베이스 마이그레이션이 완료되었는가? 5. ✅ Redis 서버가 실행 중인가? (통합 테스트의 경우) ## 빠른 테스트 실행 ```bash # 가상환경 활성화 후 cd /home/jhpark/workspace/O2Sound_ver2/backend # 모든 테스트 실행 ./run-tests.sh # 특정 테스트만 실행 (에러 없는 것만) poetry run pytest tests/api/v1/test_auth.py -v poetry run pytest tests/api/v1/test_user.py -v # 에러가 발생하는 테스트 제외 poetry run pytest tests/ -v --ignore=tests/test_database_integration.py --ignore=tests/test_integration_scenarios.py ```