temporal-python-testing

Test Temporal Python workflows with pytest, time-skipping, mocking, and replay validation.

Updated May 20, 2026
One-click install
npx skills add https://github.com/TechCorp25/kingdom --skill temporal-python-testing-techcorp25
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: temporal-python-testing
Source: https://github.com/TechCorp25/kingdom/tree/main/.claude/skills/backend-development/skills/temporal-python-testing
Command: npx skills add https://github.com/TechCorp25/kingdom --skill temporal-python-testing-techcorp25

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires temporalio, pytest, pytest-asyncio, pytest-cov, pytest-xdist, and includes references (resource) components.

What problem does it solve? Testing Temporal workflows is challenging because long-running timers, external activity calls, and determinism requirements make naive tests slow and flaky. This Skill provides structured patterns for unit, integration, and replay testing so workflow code can be validated quickly and safely before deployment. ## Core Features & Use Cases - Unit Testing with Time-Skipping: Run month-long workflows in seconds using WorkflowEnvironment, and test activities in isolation with ActivityEnvironment. - Integration Testing with Mocked Activities: Mock external dependencies, inject transient and non-retryable errors, and test signals, queries, and parallel activity orchestration. - Replay Testing for Determinism: Validate workflow code changes against production histories to catch non-deterministic behavior before deployment. - Local Development Setup: Docker Compose configuration for a local Temporal server, pytest configuration, coverage targets, and CI/CD pipeline examples. - Use Case: Before deploying a refactored order-processing workflow, replay it against exported production histories to confirm the new code produces identical decisions and is safe to ship. ## Quick Start Ask the AI to write a pytest unit test for a Temporal workflow using the time-skipping WorkflowEnvironment with a mocked activity.

Frequently Asked Questions about temporal-python-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I test Temporal workflows in Python with pytest?▼

Use WorkflowEnvironment.start_time_skipping() from temporalio.testing to create a test environment where workflow sleeps complete instantly. Run a Worker with your workflows and activities, then execute the workflow through the environment client and assert on the result.

How to mock Temporal activities in workflow tests?▼

Pass a mock function or a test double in place of the real activity when constructing the Worker in your test. This isolates workflow orchestration logic from external services and lets you simulate success, transient failures, and non-retryable ApplicationError cases.

What is replay testing in Temporal and why does it matter?▼

Replay testing re-executes workflow code against recorded event histories using the Replayer class. If the new code makes the same decisions as the recorded history, the change is deterministic and safe to deploy; mismatches indicate breaking changes.

Why does my Temporal workflow fail determinism checks?▼

Non-determinism comes from using random.randint, datetime.now, or direct external API calls inside workflow code. Replace these with workflow.random(), workflow.now(), and activities so replayed executions produce identical decisions.

How do I set up a local Temporal server for development?▼

Use Docker Compose with the temporalio/auto-setup image and a PostgreSQL container, exposing port 7233 for the server and 8080 for the Web UI. Verify connectivity with a health check script that connects a client and executes a simple workflow.

What test coverage should Temporal workflows have?▼

Temporal best practices recommend at least 80 percent coverage for workflow and activity logic. Combine unit tests with time-skipping, integration tests with mocked activities, and replay tests against production histories before every deployment.