This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Dependency Injection for startup in test client #4183
Labels
You can continue the conversation there. Go to discussion →
First Check
Commit to Help
Example Code
Description
Is it possible to pass an argument to the startup function of the TestClient?
https://fastapi.tiangolo.com/advanced/testing-events/
The docs suggest using TestClient to ensure the startup function gets invoked, but what if the startup function has an argument that is a class that hits a remote and Id like to mock it. Since patching module can be finicky dependency injection is a clean way to accomplish the goal of mocking an object and if something like I suggested in the example code was implemented it would make this very easy.
Operating System
macOS
Operating System Details
No response
FastAPI Version
0.70.0
Python Version
Python 3.9.7
Additional Context
No response
The text was updated successfully, but these errors were encountered: