3 ways to test S3 in Python
summary
A tiny 20-line CRUD app stores recipes in S3 and tests run three ways: botocore stubs, moto, and LocalStack. Botocore stubs work but prove fragile and verbose; tests require brittle fake responses. Moto and LocalStack both implement the S3 API, let tests run unchanged, and actually catch bugs seen in production. Recommendation: use moto for pure Python projects, use LocalStack when a more realistic, cross-language environment or heavier IO testing is needed. Tests reach ~100% coverage for the example.
AI-written summary · about
chapters (9)
- 0:00Testing S3 in Python
- 2:31Why S3 testing matters
- 4:36BottleCore stubs limits
- 11:00Moto for S3 mocking
- 15:30LocalStack for AWS testing
- 18:17Moto vs LocalStack
- 20:21Bugs caught by S3 tests
- 22:51Choosing Moto or LocalStack
- 23:12Q&A
related talks
26mTesting Infrastructure as Code Using OpenTofu and Localstack
24mTesting Your Python Code
35mTesting: Choose Your Weapons
59mTesting in Python
23mPython in the Cloud: Getting Started with AWS and Boto3
28m"WHAT IS THIS MESS?" - Writing tests for pre-existing code bases
32mEasy, Breezy, Beautiful... Django Unit Tests with Colleen Dunlap
41mTesting is Fun in Python!
