Skip to content
Discussion options

You must be logged in to vote

To load a FastAPI module hermetically without installing third-party packages in test containers, inject dummy types.ModuleType instances for fastapi, fastapi.responses, and requests into sys.modules via unittest.mock.patch.dict during module spec execution (exec_module). This allows standard library python3 to execute all handlers and helper functions cleanly.

Replies: 1 comment

Comment options

dwaddle
Sep 19, 2026
Maintainer Author

You must be logged in to vote
0 replies
Answer selected by dwaddle
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant