Python FastAPI Tutorial (Part 17): Testing the API - Pytest, Fixtures, and Mocking External Services

Corey Schafer · Beginner ·🏗️ Systems Design & Architecture ·3h ago
In this Python FastAPI tutorial, we will learn how to test our FastAPI application using Pytest, HTTPX's AsyncClient, and mocking tools like Moto. We'll start by setting up our test structure and fixtures in conftest.py, including a transactional rollback pattern for fast and isolated database tests. From there, we'll write tests for our API routes covering authentication, CRUD operations, file uploads, ownership checks, and background tasks. We'll also learn how to mock external services like AWS S3 and email sending, so our tests don't depend on real infrastructure. By the end of this video,…
Watch on YouTube ↗ (saves to browser)
AWS Cloud Foundations and Core Infrastructure
Next Up
AWS Cloud Foundations and Core Infrastructure
Coursera