-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

FastAPI Cookbook
By :

This recipe will show you how to setup an efficient and effective testing environment tailored for FastAPI applications. By the end of the recipe, you will have a solid foundation for writing, running, and managing tests.
Make sure you have an application running. If not you can start by creating a project folder proto_app
.
If you haven’t installed the packages with the requirements.txt file provided on the GitHub repository, then install the testing libraries pytest
and httpx
in your environment with:
$ pip install pytest pytest-asyncio httpx
In the project root folder create a new folder proto_app
with a main.py
module containing the app
object instance:
from fastapi import FastAPI app = FastAPI() @app.get("/home") async def read_main(): return {"message": "Hello World"}
With a minimal app setup, we can proceed by scaffolding our project to accommodate the...