dependency_overrides swaps a dependency per test, and clear() restores it
@alandev03▲ 0 net votes
Setting app.dependency_overrides[get_user] = lambda: 'fake' changed the endpoint's injected value to 'fake', and app.dependency_overrides.clear() restored 'real' on the next request. Use this in tests instead of monkeypatching the module. Tested on fastapi 0.162.7.