# Python workflow testing examples?

**URL:** <https://community.temporal.io/t/python-workflow-testing-examples/5792>\
**Category:** Community Support\
**Tags:** python-sdk\
**Created:** [August 25, 2022, 5:09pm UTC](https://community.temporal.io/t/python-workflow-testing-examples/5792 "2022-08-25T17:09:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![pleases.borderland](https://avatars.discourse-cdn.com/v4/letter/p/eada6e/32.png) [@pleases.borderland](https://community.temporal.io/u/pleases.borderland)\
**Post date:** [August 25, 2022, 5:09pm UTC](https://community.temporal.io/t/python-workflow-testing-examples/5792/1 "2022-08-25T17:09:40Z")

</div>

Hi! 👋 I’m looking to understand how testing of workflows defined in the Python SDK can be accomplished. Testing activities seems simple enough, i.e., it’s really no different from testing any other function. I didn’t see any obvious guidance in the sdk-python repo, nor in [GitHub - temporalio/samples-python: Samples for working with the Temporal Python SDK](https://github.com/temporalio/samples-python) .

**Can anyone provide guidance and/or examples on testing workflows defined in Python?**

---

<div class="post-metadata">

**Author:** ![jreynolds23](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/jreynolds23/32/1998_2.png) [@jreynolds23](https://community.temporal.io/u/jreynolds23)\
**Post date:** [August 25, 2022, 5:46pm UTC](https://community.temporal.io/t/python-workflow-testing-examples/5792/2 "2022-08-25T17:46:29Z")

</div>

Hi @pleases.borderland

Here is a more in detail example of a workflow using python: [GitHub - temporalio/sdk-python: Temporal Python SDK](https://github.com/temporalio/sdk-python). Further down there is more information going over how to run a workflow, invoking activities, invoking child workflows, timers, conditions, asyncio and cancellation, workflow utilities, exceptions, etc…

Let me know if this is resourceful.

Best Regards,  
Jordan

---

<div class="post-metadata">

**Author:** ![pleases.borderland](https://avatars.discourse-cdn.com/v4/letter/p/eada6e/32.png) [@pleases.borderland](https://community.temporal.io/u/pleases.borderland)\
**Post date:** [August 25, 2022, 5:51pm UTC](https://community.temporal.io/t/python-workflow-testing-examples/5792/3 "2022-08-25T17:51:47Z")

</div>

Thanks for the reply, @jreynolds23 !

The link you shared definitely provides guidance on **running** workflows, but I can’t find anything describing **writing unit/integration tests** for workflows. Do you happen to know of code samples of tests covering workflow code?

Thanks again!

---

<div class="post-metadata">

**Author:** ![Chad\_Retz](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/chad_retz/32/1396_2.png) [@Chad\_Retz](https://community.temporal.io/u/Chad_Retz)\
**Post date:** [August 25, 2022, 7:47pm UTC](https://community.temporal.io/t/python-workflow-testing-examples/5792/4 "2022-08-25T19:47:11Z")

</div>

The test framework to make unit testing of activities and workflows in Python is under active development. I hope to complete it soon. I will update [Test framework · Issue #81 · temporalio/sdk-python · GitHub](https://github.com/temporalio/sdk-python/issues/81) when the PR is available.

In the meantime, some users write integration tests using a real Temporal server (e.g. Temporalite). In fact, the Python SDK tests are written this way.

---

<div class="post-metadata">

**Author:** ![Matt\_Gurney](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/matt_gurney/32/1851_2.png) [@Matt\_Gurney](https://community.temporal.io/u/Matt_Gurney)\
**Post date:** [November 24, 2022, 2:20am UTC](https://community.temporal.io/t/python-workflow-testing-examples/5792/6 "2022-11-24T02:20:01Z")

</div>

Hi @Chad_Retz , I see that Github issue is closed, but I am not aware of any further framework for writing tests for activities and workflows implemented in Python other than using a real Temporal instance (Temporalite) or using native Python testing mocking within Pytest for example. Am I missing something?

---

<div class="post-metadata">

**Author:** ![Chad\_Retz](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/chad_retz/32/1396_2.png) [@Chad\_Retz](https://community.temporal.io/u/Chad_Retz)\
**Post date:** [November 24, 2022, 2:34am UTC](https://community.temporal.io/t/python-workflow-testing-examples/5792/7 "2022-11-24T02:34:35Z")

</div>

> Am I missing something?

Many people use the time-skipping server to test in their unit test framework of choice. Pytest is just one example. See the [Testing section of the README](https://github.com/temporalio/sdk-python#testing) or look at [example tests](https://github.com/temporalio/samples-python/blob/main/tests/hello/hello_activity_test.py) which use a server defined in [conftest.py](https://github.com/temporalio/samples-python/blob/main/tests/conftest.py) for Pytest.
