diff --git a/docs/source/devel/testloop.rst b/docs/source/devel/testloop.rst index 3c20a26..9df88b4 100644 --- a/docs/source/devel/testloop.rst +++ b/docs/source/devel/testloop.rst @@ -21,8 +21,6 @@ to an ``async def`` test case. Async commands ============== -.. autoclass:: PingPong - .. autoclass:: Schedule(*await Any) .. py:class:: Switch(skip: int, /) diff --git a/unittests/test_builtins.py b/unittests/test_builtins.py index c1a64d7..6231b4b 100644 --- a/unittests/test_builtins.py +++ b/unittests/test_builtins.py @@ -4,7 +4,7 @@ import asyncstdlib as a -from .utility import sync, asyncify, awaitify, inside_loop +from .utility import sync, asyncify, awaitify def hide_coroutine(corofunc): @@ -83,8 +83,7 @@ async def __aiter__(self): yield 1 finally: nonlocal closed - if await inside_loop(): - closed = True + closed = True zip_iter = a.zip(asyncify(range(-5, 0)), SomeIterable()) async for va, vb in zip_iter: diff --git a/unittests/utility.py b/unittests/utility.py index c901a3f..479278d 100644 --- a/unittests/utility.py +++ b/unittests/utility.py @@ -1,7 +1,6 @@ from typing import ( Callable, Coroutine, - Generator, Iterable, AsyncIterator, TypeVar, @@ -45,25 +44,6 @@ async def await_wrapper(*args: Any, **kwargs: Any) -> T: return await_wrapper -class PingPong: - """ - Signal to the event loop which gets returned unchanged - - The coroutine yields to the event loop but is resumed - immediately, without running others in the meantime. - This is mainly useful for ensuring the event loop is used. - """ - - def __await__(self) -> "Generator[PingPong, Any, Any]": - return (yield self) - - -async def inside_loop() -> bool: - """Test whether there is an active event loop available""" - signal = PingPong() - return await signal is signal - - class Schedule: r""" Signal to the event loop to adopt and run new coroutines @@ -136,9 +116,7 @@ def sync(test_case: Callable[..., Coroutine[None, Any, Any]], /) -> Callable[... Mark an ``async def`` test case to be run synchronously with children This provides a primitive "event loop" which only responds - to the :py:class:`PingPong`, :py:class:`Schedule`, :py:class:`Switch` - and :py:class:`Lock`. This loop is appropriate for tests that need - to check concurrency. + to :py:class:`Schedule`, :py:class:`Switch` and :py:class:`Lock`. It should be applied as a decorator on an ``async def`` function, which is then turned into a synchronous callable that will run the ``async def`` @@ -159,9 +137,7 @@ def run_sync(*args: Any, **kwargs: Any): result = e.args[0] if e.args else None assert result is None, f"got '{result!r}' expected 'None'" else: - if isinstance(event, PingPong): - run_queue.appendleft((coro, event)) - elif isinstance(event, Schedule): + if isinstance(event, Schedule): run_queue.extend((new_coro, None) for new_coro in event.coros) run_queue.append((coro, event)) elif isinstance(event, Switch):