Skip to main content
The Python SDK has an asynchronous testing harness for testing Restate handlers against a real Restate Server. This uses Testcontainers to run a Restate Server in a Docker container and provides a client to let you test your Restate handlers.

Setup

You need Python 3.10 or newer and a running Docker environment. Install the package:

Testing handlers

If you have a service as follows:
Then test it with create_test_harness and the typed asynchronous ingress client:
create_test_harness starts the application and Restate Server, registers the application, and stops both when the context exits. The returned harness provides:
  • harness.client: A typed asynchronous client for invoking Services, Virtual Objects, and Workflows
  • harness.ingress_url: The HTTP ingress URL for raw HTTP tests
  • harness.admin_api_url: The Admin API URL for deployment and introspection assertions

Testing options

Use the harness options to exercise failure and replay behavior: Use always_replay=True for tests to find non-determinism bugs. Use disable_retries=True in focused failure tests where you need the first retryable failure to be observable immediately.