A pytest fixture that allows easy replacement of FastAPI dependencies for testing. Version 0.2.3 (PyPI). It wraps FastAPI's dependency override mechanism in a clean fixture, enabling overrides at the test level with context managers. Release cadence is irregular.
pip install pytest-fastapi-depsVerified import paths — ran on the pinned version, not inferred.
Basic usage: override a dependency with a lambda.
Use `with fastapi_dep(app).override(...)` instead of assigning the fixture to a variable without entering the context.
Upgrade to 0.2.0+ or wrap plain objects in a lambda: `lambda: 'value'`
Create a new app or use separate fixtures to avoid cross-test contamination.
Use `from pytest_fastapi_deps import fastapi_dep` (singular).
Upgrade to 0.2.0+ or wrap the value in a lambda: `override={get_token: lambda: value}`Use the method as a context manager: `with fastapi_dep(app).override(...):`
No dependency data recorded yet.