Serverless Unit Testing with Moto

Serverless development can speed up your development process a lot by moving infrastructure responsibilities over to cloud providers. However, when testing your application, it can be a challenge to mimic all the cloud services you’re relying on.

One useful tool to help do this when you’re writing Python code is moto. In this post, I’ll show you how to use the moto module in combination with pytest to help test your Python code when it interacts with AWS services like DynamoDB, S3 and others.

A few days ago I needed to test a Lambda function build script for my recent Pluralsight course on a Windows machine. One of my course viewers notices that the bash build script I’d written for unix environments was incompatible with Windows bash. Because of this I needed to write a custom .bat script for windows environments. Only one problem, I don’t own a Windows machine, and I don’t want to.