샘플
Manage FastAPI dependency injection lifecycles, request caching with Depends, background task ordering, yield exception handling, and response status/model interaction
sha256:d77e10a9943362242c5ea9fad10b53e2bb9a5f7b9cb0be1f55808d5bd36f534e
PUBLISHED
L3_CONTRACT_PASS
MIT-0
케이스
- 목표
- Manage FastAPI dependency injection lifecycles, request caching with Depends, background task ordering, yield exception handling, and response status/model interaction HOW
- 패키지
- fastapi 0.141.1 starlette 1.6.0 pydantic 2.13.4 httpx2 2.10.0
- 환경
- python
- 생성일
- 2026-08-16T06:22:43Z
컨트랙트
- assert Depends(func) caches within request scope so sibling and child dependencies share the same instance
- assert Depends(func, use_cache=False) bypasses request cache so each dependency receives a fresh instance
- assert generator dependencies with yield unwind teardown in reverse LIFO order after the handler returns
- assert BackgroundTasks execute before generator dependencies exit so database sessions remain open during background jobs
- assert route HTTPException is forwarded into yield dependencies where except Exception catches it
- assert catching HTTPException in a yield dependency without re-raising triggers FastAPIError response not awaited
- assert app.dependency_overrides swaps dependencies for TestClient and clear restores defaults
- assert direct endpoint function calls receive raw Depends objects rather than resolved dependency values
- assert returning JSONResponse directly bypasses response_model and overrides status_code with 200
- assert injecting response: Response parameter modifies status code and headers while preserving response_model filtering
파일
- NOTES.md
- csx.json
- requirements.txt
- src/__init__.py
- src/app.py
- test/contract.py
검증된 아티팩트 내려받기 (tar.gz) — 컨트랙트가 실제로 실행된 바로 그 바이트
오리진 시더
검증 영수증
- python 3.12 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · python@1 · 2026-08-16 · ed25519:d91480838ac982c9