Skip to main content

testcontainers-understudy

Runs understudy, the local AWS emulator, as a Testcontainers for Python module.

It is released with understudy: version X.Y.Z of this package defaults to the image ghcr.io/sustinbebustin/understudy:X.Y.Z. Nothing is published yet, so build the image with just image, pass understudy:dev, and install the package from a clone, here at ../understudy:

uv add --dev ../understudy/testcontainers/python

It needs Python 3.10 or later and testcontainers>=4.15,<5.

Use

import boto3
import pytest
from testcontainers_understudy import UnderstudyContainer


@pytest.fixture(scope="session")
def understudy():
    with UnderstudyContainer("understudy:dev") as u:
        yield u


@pytest.fixture(autouse=True)
def aws_env(understudy, monkeypatch):
    for name, value in understudy.get_env().items():  # AWS_ENDPOINT_URL, test credentials, us-east-1
        monkeypatch.setenv(name, value)
    yield
    understudy.reset()


def test_orders_queue():
    sqs = boto3.client("sqs")
    url = sqs.create_queue(QueueName="orders")["QueueUrl"]
    sqs.send_message(QueueUrl=url, MessageBody="order-1")
    assert [m["Body"] for m in sqs.receive_message(QueueUrl=url)["Messages"]] == ["order-1"]

start() publishes port 4566 on 127.0.0.1 only and returns once GET /_understudy/v1/health answers 200 with "ready": true; if understudy exits first, it raises with understudy's log. A start() that raises once the container exists has already stopped and removed it. stop(), and leaving the with block, stops understudy with a 10-second grace period, which lets it remove the Lambda and DynamoDB Local containers it started, and every such container carries the session's label, so Ryuk removes them too.

Options

Method Effect
with_docker_socket() mounts the Docker socket and adds its group (0 on Docker Desktop, whose VM owns the socket), for Lambda and DynamoDB Local; start() raises UnderstudyDockerError unless understudy then reports Docker enabled
with_docker_socket(gid=n) the same, with the group given, for a daemon that is not a local unix socket
with_clock(frozen_at=dt, scale=f) the emulator clock; frozen_at must be timezone-aware
with_seed(n) repeatable generated identifiers
with_sigv4_verify() verify request signatures
with_snapshot(path) load a snapshot archive at start
with_admin_token() a random admin token, sent by the wait and the helpers
with_published_on(addr) publish on another address; beyond loopback only with with_admin_token(); a loopback address other than 127.0.0.1 is refused, since the endpoint never dials it

with_env sets any other UNDERSTUDY_* setting. settle(timeout), advance_clock(by) and reset() wrap the common admin calls and raise UnderstudyAdminError on an error answer. Misconfigurations raise UnderstudyConfigError, before any container is created. The exception is a missing snapshot archive: with_snapshot raises FileNotFoundError for it.

The Testcontainers guide covers Lambda, Terraform and cleanup in more detail.

Development

just image
testcontainers/python/run.sh    # uv sync, ruff check and format check, sealed pytest against understudy:dev

UNDERSTUDY_IMAGE selects another image; extra arguments go to pytest.

Metadata

Release files for testcontainers-understudy 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for testcontainers-understudy 0.1.2
File Size Uploaded Provenance Actions
testcontainers_understudy-0.1.2.tar.gz 9.8 kB Without provenance Details for testcontainers_understudy-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for testcontainers-understudy 0.1.2
File Interpreter ABI Platform Actions
testcontainers_understudy-0.1.2-py3-none-any.whl Python 3 none any Details for testcontainers_understudy-0.1.2-py3-none-any.whl

Total release size: 20.6 kB

Release files / testcontainers_understudy-0.1.2.tar.gz

Download URL testcontainers_understudy-0.1.2.tar.gz
Size 9.8 kB
Tags Source
SHA-256 checksum
How to use checksums
03b4d00f642f0d35db5db4e3ee446ea65a9eeaa13d4817311a858925848c417d
BLAKE2b-256 checksum
How to use checksums
78d29eaf17c53bfd34473e5a734a9a51f9665ff65c3eca7f8ba9c992b14233c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / testcontainers_understudy-0.1.2-py3-none-any.whl

Download URL testcontainers_understudy-0.1.2-py3-none-any.whl
Size 10.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0ca415cca4193feafc24607d51a91e97f2c7bad95d9f7301bfc9f7cc0d2fc522
BLAKE2b-256 checksum
How to use checksums
d665c6e636299282f74529a093809f87239790d5a33e73d9302ea09cfe398008
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for testcontainers-understudy 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page