AWS Durable Execution Testing SDK for Python
Archived. The repository is read-only: no more fixes or releases will come.
pip install aws-durable-execution-sdk-python-testingAWS Durable Execution Testing SDK for Python
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: