Skip to content

Commit c3e051b

Browse files
author
Anton
committed
tests: new test case
1 parent 5971625 commit c3e051b

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

‎tests/receiver/test_receiver.py‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import random
33
import time
44
from concurrent.futures import ThreadPoolExecutor
5+
from functools import wraps
56
from typing import Any, ClassVar, List, Optional
67

78
import pytest
@@ -472,3 +473,31 @@ async def task_no_result() -> str:
472473
assert resp.return_value is None
473474
assert not broker._running_tasks
474475
assert isinstance(resp.error, ValueError)
476+
477+
478+
@pytest.mark.anyio
479+
async def test_sync_decorator_on_async_function() -> None:
480+
broker = InMemoryBroker()
481+
wrapper_call = False
482+
483+
def wrapper(f: Any) -> Any:
484+
@wraps(f)
485+
def wrapper_impl(*args: Any, **kwargs: Any) -> Any:
486+
nonlocal wrapper_call
487+
488+
wrapper_call = True
489+
return f(*args, **kwargs)
490+
491+
return wrapper_impl
492+
493+
@broker.task
494+
@wrapper
495+
async def task_no_result() -> str:
496+
return "some value"
497+
498+
task = await task_no_result.kiq()
499+
resp = await task.wait_result(timeout=1)
500+
501+
assert resp.return_value == "some value"
502+
assert not broker._running_tasks
503+
assert wrapper_call is True

0 commit comments

Comments
 (0)