Mark a test function written in a :func:`twisted.internet.defer.inlineCallbacks` style. This calls :func:`twisted.internet.defer.inlineCallbacks` and then: * with ``pytest-twisted`` this returns the resulting Deferred * with ``pytest-asyncio`` this converts the resulting Deferred into
(
f: Callable[_P, Generator[Deferred[Any], Any, None]],
)
| 17 | |
| 18 | |
| 19 | def inline_callbacks_test( |
| 20 | f: Callable[_P, Generator[Deferred[Any], Any, None]], |
| 21 | ) -> Callable[_P, Awaitable[None]]: |
| 22 | """Mark a test function written in a :func:`twisted.internet.defer.inlineCallbacks` style. |
| 23 | |
| 24 | This calls :func:`twisted.internet.defer.inlineCallbacks` and then: |
| 25 | |
| 26 | * with ``pytest-twisted`` this returns the resulting Deferred |
| 27 | * with ``pytest-asyncio`` this converts the resulting Deferred into a |
| 28 | coroutine |
| 29 | """ |
| 30 | |
| 31 | if not is_reactor_installed(): |
| 32 | |
| 33 | @pytest.mark.asyncio |
| 34 | @wraps(f) |
| 35 | async def wrapper_coro(*args: _P.args, **kwargs: _P.kwargs) -> None: |
| 36 | await deferred_to_future(inlineCallbacks(f)(*args, **kwargs)) |
| 37 | |
| 38 | # Likely https://github.com/python/mypy/issues/17171 |
| 39 | return wrapper_coro # type: ignore[no-any-return] |
| 40 | |
| 41 | @wraps(f) |
| 42 | @inlineCallbacks |
| 43 | def wrapper_dfd( |
| 44 | *args: _P.args, **kwargs: _P.kwargs |
| 45 | ) -> Generator[Deferred[Any], Any, None]: |
| 46 | return f(*args, **kwargs) |
| 47 | |
| 48 | return wrapper_dfd |
| 49 | |
| 50 | |
| 51 | def coroutine_test( |
nothing calls this directly
no test coverage detected