moto
A library that allows you to easily mock out tests based on AWS infrastructure.
Moto is a Python library that intercepts AWS API calls during tests and handles them in memory, so you can test code that uses AWS without connecting to real cloud services.
Moto is a Python library that lets you test code that uses Amazon Web Services without actually connecting to AWS. When you run tests, Moto intercepts the calls your code makes to AWS services and handles them in memory instead, simulating the behavior of real AWS without any cost, network dependency, or risk of accidentally modifying real infrastructure.
The way it works is straightforward. You wrap a test function with a decorator from Moto, and from that point on, any AWS calls inside that function hit a fake in-memory version of the service instead of the real one. The fake service keeps track of state as the test runs, so if your code creates an S3 bucket and then uploads a file to it, Moto remembers both the bucket and the file, and a subsequent read will return the right data.
Moto supports a wide range of AWS services. The ones most commonly used include S3 (object storage), EC2 (virtual machines), and many others. A full list of covered services and features is maintained in the repository's implementation coverage file.
Installation is through pip, Python's package manager. You install only the services you need, for example moto[s3] for S3 or moto[all] for everything. The library is used alongside boto3, which is the standard AWS SDK for Python. It is released under an open-source license and supported financially through OpenCollective sponsorship.
Where it fits
- Test code that creates S3 buckets and uploads files without connecting to real AWS
- Run unit tests for Lambda or DynamoDB logic in memory without cloud costs
- Simulate AWS service behavior in CI pipelines to validate infrastructure scripts