{"library":"pytest-fastapi-deps","title":"pytest-fastapi-deps","description":"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.","language":"python","status":"active","last_verified":"Mon Apr 27","install":{"commands":["pip install pytest-fastapi-deps"],"cli":null},"imports":["from pytest_fastapi_deps import fastapi_dep"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"from fastapi import FastAPI, Depends\nfrom pytest_fastapi_deps import fastapi_dep\n\napp = FastAPI()\n\ndef get_token():\n    return \"original\"\n\n@app.get(\"/token\")\ndef read_token(token: str = Depends(get_token)):\n    return {\"token\": token}\n\n# In test file\nimport pytest\nfrom fastapi.testclient import TestClient\n\n@pytest.fixture\ndef client():\n    with fastapi_dep(app).override({get_token: lambda: \"overridden\"}):\n        yield TestClient(app)\n\ndef test_token(client):\n    response = client.get(\"/token\")\n    assert response.json() == {\"token\": \"overridden\"}","lang":"python","description":"Basic usage: override a dependency with a lambda.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}