Python activity test

Can anyone suggest how to write temporal test case for activity. I was following https://github.com/temporalio/samples-python/blob/ecdfcd69b7a7894d5ed847549c0f045d41bdcb67/tests/hello/hello_activity_test.py#L4 but it is showing that i am missing client.

Then i referred (https://github.com/temporalio/samples-python/blob/ecdfcd69b7a7894d5ed847549c0f045d41bdcb67/tests/conftest.py)
to create client but it gave

async def client(env: WorkflowEnvironment) -> Client:
  return env.client

E AttributeError: ‘async_generator’ object has no attribute ‘client’

Please suggest how can i write the test case for activity in python

You don’t need a client for testing activities. Since they are just functions with a couple of context-available pieces, the temporalio.testing.ActivityEnvironment can be used. See the activity testing section of the Python dev guide.

1 Like