temporal-python-testing

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

Updated Apr 23, 2026
One-click install
npx skills add https://github.com/SanketAdlak/PDMProjectDesign --skill temporal-python-testing-sanketadlak
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: temporal-python-testing
Source: https://github.com/SanketAdlak/PDMProjectDesign/tree/main/.agents/skills/temporal-python-testing
Command: npx skills add https://github.com/SanketAdlak/PDMProjectDesign --skill temporal-python-testing-sanketadlak

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Testing Temporal workflows is challenging because long-running timers, external activity dependencies, and determinism requirements make naive tests slow and flaky. This Skill provides structured patterns for unit, integration, and replay testing of Temporal Python workflows so tests run fast and catch breaking changes before deployment. ## Core Features & Use Cases - Unit Testing with Time-Skipping: Use WorkflowEnvironment and ActivityEnvironment to test workflows and activities in isolation, completing month-long timers in seconds. - Integration Testing with Mocked Activities: Mock external services, 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 detect non-deterministic behavior before deployment. - Local Development Setup: Docker Compose configuration, pytest fixtures, coverage targets (≥80%), and CI/CD pipeline examples. - Use Case: Before deploying a refactored order-processing workflow, replay it against exported production histories in CI 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 your Temporal workflow using WorkflowEnvironment with time-skipping and 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 inside the environment, then execute the workflow via the client and assert on the result.

How to mock Temporal activities in workflow tests?

Pass a mock function or a test double activity to the Worker's activities list instead of the real activity. This isolates workflow orchestration logic from external services, and you can use dynamic mocks to simulate success, transient failures, or 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 replay after a code change?

Replay fails when code changes alter the sequence of workflow commands, such as adding or reordering activity calls. Use workflow.get_version() for backward-compatible changes, and avoid non-deterministic calls like random.randint, datetime.now, or direct HTTP requests inside workflows.

How do I test a Temporal activity without a workflow?

Use ActivityEnvironment from temporalio.testing to run an activity directly without a workflow or server. It supports testing heartbeats, cancellation handling, and exception propagation by passing inputs and asserting on outputs or raised errors.

What test coverage should Temporal workflows have?

Temporal's recommended target is at least 80 percent coverage for both workflow and activity logic. Combine unit tests with time-skipping, integration tests with mocked activities for critical paths, and replay tests for all workflow versions before deployment.