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.
uv add --dev testcontainers-understudy # or: pip install testcontainers-understudy
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() 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.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| testcontainers_understudy-0.2.0.tar.gz | 9.8 kB | Without provenance | Details for testcontainers_understudy-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| testcontainers_understudy-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for testcontainers_understudy-0.2.0-py3-none-any.whl |
Total release size: 20.4 kB
Release files / testcontainers_understudy-0.2.0.tar.gz
| Download URL | testcontainers_understudy-0.2.0.tar.gz |
|---|---|
| Size | 9.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
47ab77585c3844a1f94dc0645795d4c3b22a9401b0175f70f6df84a5149160bc
|
|
BLAKE2b-256 checksum How to use checksums |
799620a51ce577c13cf2fe76dc7046585d20a6f54c96eb85ca72a1e6d9762873
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","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.2.0-py3-none-any.whl
| Download URL | testcontainers_understudy-0.2.0-py3-none-any.whl |
|---|---|
| Size | 10.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b2f4d927b7dba5eb164103e6ccbc7670806594993ee2f131aa6f49318cc0f9f7
|
|
BLAKE2b-256 checksum How to use checksums |
4d1187b354075bc2726a6cbbc32444ab3536c912b305be9172d113a25c21f49d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","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.2.0
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.