Skip to content

Commit 4f7e85b

Browse files
committed
More async detection tests
Signed-off-by: Sergio Herrera <627709+seherv@users.noreply.github.com>
1 parent 5fb88e6 commit 4f7e85b

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

ext/dapr-ext-workflow/tests/test_async_activity_registration.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,27 @@ def __call__(self, ctx: object, inp: object) -> str:
236236

237237
self.assertFalse(_is_async_callable(SyncCallable()))
238238

239+
def test_cyclic_wrapped_chain_does_not_crash(self) -> None:
240+
"""A self-referential ``__wrapped__`` makes ``inspect.unwrap`` raise; detection must
241+
fall back to the outermost callable instead of propagating the error."""
242+
243+
async def async_cyclic() -> None: ...
244+
245+
async_cyclic.__wrapped__ = async_cyclic # type: ignore[attr-defined]
246+
247+
def sync_cyclic() -> None: ...
248+
249+
sync_cyclic.__wrapped__ = sync_cyclic # type: ignore[attr-defined]
250+
251+
self.assertTrue(_is_async_callable(async_cyclic))
252+
self.assertFalse(_is_async_callable(sync_cyclic))
253+
254+
def test_non_callable_input_is_not_async(self) -> None:
255+
"""The worker passes ``None`` for an unregistered activity and relies on a False
256+
result to route to the sync handler."""
257+
self.assertFalse(_is_async_callable(None))
258+
self.assertFalse(_is_async_callable(42))
259+
239260

240261
class AsyncAndSyncCoexistTest(_AsyncActivityRegistrationTestBase):
241262
def test_runtime_registers_mixed_sync_and_async_activities(self) -> None:

0 commit comments

Comments
 (0)