pytest plugin for the substrate AWS emulator.
pip install pytest-substrate
# or, from source:
pip install -e /path/to/substrate/pythonAdd the substrate fixture to any test that needs AWS services:
import boto3
def test_s3_upload(substrate):
s3 = boto3.client("s3")
s3.create_bucket(Bucket="my-bucket")
s3.put_object(Bucket="my-bucket", Key="hello.txt", Body=b"hello")
obj = s3.get_object(Bucket="my-bucket", Key="hello.txt")
assert obj["Body"].read() == b"hello"The substrate fixture:
- Starts a substrate server once per test session (via
substrate_server) - Resets all state before each test
- Sets
AWS_ENDPOINT_URL,AWS_DEFAULT_REGION, and dummy credentials viamonkeypatch
Manages the substrate process lifecycle. Starts once, stops after all tests complete.
Resets state and configures env vars. Yields the SubstrateServer instance.
Set SUBSTRATE_BINARY to override the binary path. Otherwise, the plugin looks for:
~/src/substrate/bin/substratesubstrateonPATH