Skip to main content

AWS Durable Execution Testing SDK for Python

PyPI - Version PyPI - Python Version OpenSSF Scorecard

Test Python durable functions locally, before you deploy them.

Install

pip install aws-durable-execution-sdk-python-testing

Requires Core SDK 3.0.2 or later, which preserves empty errors when saved execution state is reloaded.

Quick start

from aws_durable_execution_sdk_python import (
    DurableContext,
    StepContext,
    durable_execution,
    durable_step,
)
from aws_durable_execution_sdk_python.config import Duration
from aws_durable_execution_sdk_python.execution import InvocationStatus
from aws_durable_execution_sdk_python_testing.runner import DurableFunctionTestRunner


@durable_step
def greet(step_ctx: StepContext, name: str) -> str:
    return f"Hello, {name}"


@durable_execution
def handler(event: dict, context: DurableContext) -> str:
    greeting = context.step(greet(event["name"]))
    context.wait(Duration.from_hours(1), name="cool-down")
    return greeting


def test_handler():
    with DurableFunctionTestRunner(handler=handler) as runner:
        result = runner.run(input='{"name": "Jane"}', execution_timeout=10)

    assert result.status is InvocationStatus.SUCCEEDED
    assert result.result == '"Hello, Jane"'
    assert result.get_step("greet").result == '"Hello, Jane"'

The runner skips waits by default, so the 1-hour wait ends at once. Pass skip_time=False to DurableFunctionTestRunner to wait in real time.

result.result and each operation's result hold the serialized value. get_step, get_wait, get_context, get_callback, and get_invoke find an operation by name.

Common uses

Complete a callback

Start the execution with run_async, then send the callback result:

from aws_durable_execution_sdk_python import DurableContext, durable_execution
from aws_durable_execution_sdk_python.execution import InvocationStatus
from aws_durable_execution_sdk_python_testing.runner import DurableFunctionTestRunner


def notify(callback_id: str, context) -> None:
    ...  # Send callback_id to the approver.


@durable_execution
def approval(event: dict, context: DurableContext) -> dict:
    decision = context.wait_for_callback(notify, name="approval")
    return {"decision": decision}


def test_approval():
    with DurableFunctionTestRunner(handler=approval) as runner:
        execution_arn = runner.run_async(input="{}", execution_timeout=10)
        callback_id = runner.wait_for_callback(execution_arn)
        runner.send_callback_success(callback_id, b"approved")
        result = runner.wait_for_result(execution_arn, timeout=10)

    assert result.status is InvocationStatus.SUCCEEDED
    assert result.result == '{"decision": "approved"}'

Test functions that invoke other functions

Register each context.invoke target with the runner. register_durable_function registers a durable target, which runs as a child durable execution. register_function registers a plain function, which runs once. An unregistered target fails the invoke with ResourceNotFoundException.

from aws_durable_execution_sdk_python import DurableContext, durable_execution
from aws_durable_execution_sdk_python_testing.runner import DurableFunctionTestRunner


@durable_execution
def process_payment(event: dict, context: DurableContext) -> dict:
    return {"charged": event["amount"]}


def lookup_price(event: dict, context) -> dict:
    return {"price": 25}


@durable_execution
def place_order(event: dict, context: DurableContext) -> dict:
    price = context.invoke("lookup-price", {"sku": event["sku"]}, name="price")
    payment = context.invoke(
        "process-payment", {"amount": price["price"]}, name="payment"
    )
    return {"sku": event["sku"], "charged": payment["charged"]}


def test_place_order():
    with DurableFunctionTestRunner(handler=place_order) as runner:
        runner.register_durable_function(
            "process-payment", process_payment, execution_timeout=60
        )
        runner.register_function("lookup-price", lookup_price)
        result = runner.run(input='{"sku": "book-1"}')

    assert result.result == '{"sku": "book-1", "charged": 25}'
    assert result.get_invoke("payment").status.value == "SUCCEEDED"

The runner matches a target by name, not by version. An invoke of child:prod runs the handler registered as child:prod if there is one, and otherwise the one registered as child.

Advanced

  • DurableFunctionCloudTestRunner(function_name=..., region=...) runs a test against a deployed function. It returns the same DurableFunctionTestResult.
  • The local runner returns errors in the same JSON format as the AWS service, so boto3 error handling works the same way. See docs/error-responses.md.

Reference

License

This project is licensed under the Apache-2.0 License.

Metadata

Release files for aws-durable-execution-sdk-python-testing 1.5.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 aws-durable-execution-sdk-python-testing 1.5.0
File Size Uploaded Provenance Actions
aws_durable_execution_sdk_python_testing-1.5.0.tar.gz 126.7 kB With provenance Details for aws_durable_execution_sdk_python_testing-1.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for aws-durable-execution-sdk-python-testing 1.5.0
File Interpreter ABI Platform Actions
aws_durable_execution_sdk_python_testing-1.5.0-py3-none-any.whl Python 3 none any Details for aws_durable_execution_sdk_python_testing-1.5.0-py3-none-any.whl

Total release size: 285.4 kB

Release files / aws_durable_execution_sdk_python_testing-1.5.0.tar.gz

Download URL aws_durable_execution_sdk_python_testing-1.5.0.tar.gz
Size 126.7 kB
Tags Source
SHA-256 checksum
How to use checksums
2ffa3370941a971375179fa941b369b8d78bf39047d86842d907f871e4977d06
BLAKE2b-256 checksum
How to use checksums
871a9a3da9916477aa6d1b6decfab3996857386d5d3d2d2d44e1d5fc4bde08c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 19, 2026.

Transparency log

Release files / aws_durable_execution_sdk_python_testing-1.5.0-py3-none-any.whl

Download URL aws_durable_execution_sdk_python_testing-1.5.0-py3-none-any.whl
Size 158.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5205fdf23d6b23623e7a387ad4c89e95fefae715ae862f7d9384437617ca4380
BLAKE2b-256 checksum
How to use checksums
fd5a22fa794402416676f93a4626da1253f15c79ab9a2fe9b0bb52bf9161bfef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 19, 2026.

Transparency log

Security for aws-durable-execution-sdk-python-testing 1.5.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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for aws_durable_execution_sdk_python_testing-1.5.0.tar.gz

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 Nov 19, 2026.

Transparency log

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.

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