Skip to main content

local-web-services-python-sdk

Python testing SDK for local-web-services — starts in-process AWS service emulators and provides pre-configured boto3 clients that point at them. Your production code works unchanged: the SDK sets AWS_ENDPOINT_URL_* environment variables that boto3 picks up automatically.

Installation

pip install local-web-services-python-sdk
# or
uv add local-web-services-python-sdk

Requires Python 3.9+ and boto3.

Quick start

from lws_testing import LwsSession, DynamoTable, SqsQueue, S3Bucket

with LwsSession(
    DynamoTable("Orders", hash_key="id"),
    SqsQueue("OrderQueue"),
    S3Bucket("my-bucket"),
) as session:
    # Get a boto3 client pointing at the local emulator
    dynamo = session.client("dynamodb")
    dynamo.put_item(TableName="Orders", Item={"id": {"S": "1"}, "status": {"S": "pending"}})

    item = dynamo.get_item(TableName="Orders", Key={"id": {"S": "1"}})
    assert item["Item"]["status"]["S"] == "pending"

    # SQS
    sqs = session.client("sqs")
    queue_url = session.queue_url("OrderQueue")
    sqs.send_message(QueueUrl=queue_url, MessageBody="hello")

    # S3
    s3 = session.client("s3")
    s3.put_object(Bucket="my-bucket", Key="file.txt", Body=b"hello")

Auto-discover resources from CDK / Terraform

# Read resource definitions from a CDK project
with LwsSession.from_cdk("../my-cdk-project") as session:
    dynamo = session.client("dynamodb")
    ...

# Read resource definitions from a Terraform project
with LwsSession.from_hcl("../my-terraform-project") as session:
    s3 = session.client("s3")
    ...

Resource specs

Declare the resources your test needs up front so LwsSession creates them before the test runs:

Spec Description
DynamoTable(name, hash_key, sort_key=None) PAY_PER_REQUEST DynamoDB table
SqsQueue(name) Standard SQS queue
S3Bucket(name) S3 bucket
SnsTopic(name) SNS topic
SsmParameter(name, value, type="String") SSM Parameter Store entry
Secret(name, value) Secrets Manager secret
StateMachine(name, definition) Step Functions state machine

pytest integration

The package registers pytest fixtures automatically via the pytest11 entry point. Add a session fixture to your conftest.py:

# conftest.py
import pytest
from lws_testing import DynamoTable, SqsQueue

@pytest.fixture(scope="session")
def lws_session_spec():
    return [
        DynamoTable("Orders", hash_key="id"),
        SqsQueue("OrderQueue"),
    ]

Then use the lws_session fixture in your tests:

def test_create_order(lws_session):
    client = lws_session.client("dynamodb")
    client.put_item(TableName="Orders", Item={"id": {"S": "42"}})
    item = client.get_item(TableName="Orders", Key={"id": {"S": "42"}})
    assert item["Item"]["id"]["S"] == "42"

Supported services

All 20 services are available via session.client(service_name):

Service session.client(...) name
DynamoDB "dynamodb"
SQS "sqs"
S3 "s3"
SNS "sns"
EventBridge "events"
Step Functions "stepfunctions"
Cognito IDP "cognito-idp"
Lambda "lambda"
API Gateway "apigateway"
RDS "rds"
DocumentDB "docdb"
SSM Parameter Store "ssm"
Secrets Manager "secretsmanager"
ElastiCache "elasticache"
Neptune "neptune"
MemoryDB "memorydb"
Glacier "glacier"
Elasticsearch "es"
OpenSearch "opensearch"
S3 Tables "s3tables"

How it works

LwsSession picks a random free base port and starts each service emulator in a background thread within the test process. It sets AWS_ENDPOINT_URL_<SERVICE> (and stub credentials) in the current process environment so that any boto3 client created during the test automatically talks to the local emulator. On __exit__ the servers are stopped and the environment is restored.

License

MIT

Metadata

Release files for local-web-services-python-sdk 0.22.0

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

Source distribution (sdist)

Source distribution for local-web-services-python-sdk 0.22.0
File Size Uploaded
local_web_services_python_sdk-0.22.0.tar.gz 656.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for local-web-services-python-sdk 0.22.0
File Interpreter ABI Platform
local_web_services_python_sdk-0.22.0-py3-none-any.whl Python 3 none any Details

Total release size: 697.6 kB

Release files / local_web_services_python_sdk-0.22.0.tar.gz

Download URL local_web_services_python_sdk-0.22.0.tar.gz
Size 656.1 kB
Tags Source
SHA-256 checksum
How to use checksums
04204390615380133e054cd575b3eb3b6d3514be9e670a605c0c8f0724eeac0a
BLAKE2b-256 checksum
How to use checksums
77382ce6dfabf289633e897034459ee68de1779c709c36894162742deaace11b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 21, 2026.

Transparency log

Release files / local_web_services_python_sdk-0.22.0-py3-none-any.whl

Download URL local_web_services_python_sdk-0.22.0-py3-none-any.whl
Size 41.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ae1d7b6e68a7e35996edd29627fc5c5edfeca85b02d196dc57b362aa1913eabf
BLAKE2b-256 checksum
How to use checksums
0c4cc4ee359f55a2b881e8528e128b890867a68c1c48b2415e0e04b306b3b7ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 21, 2026.

Transparency log

Release history Release notifications | RSS feed

0.24.0

2 release files

0.23.0

2 release files

This release

0.22.0 This release

2 release files

0.21.0

2 release files

0.20.0

2 release files

0.19.0

2 release files

0.2.0

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

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