def setup_test_loop(
    loop_factory: _LOOP_FACTORY = asyncio.new_event_loop,
) -> asyncio.AbstractEventLoop:
    """Create and return an asyncio.BaseEventLoop instance.

    The caller should also call teardown_test_loop,
    once they are done with the loop.
    """
    loop = loop_factory()
    try:
        module = loop.__class__.__module__
        skip_watcher = "uvloop" in module
    except AttributeError:  # pragma: no cover
        # Just in case
        skip_watcher = True
    asyncio.set_event_loop(loop)
    if sys.platform != "win32" and not skip_watcher:
        policy = asyncio.get_event_loop_policy()
        watcher: asyncio.AbstractChildWatcher
        try:  # Python >= 3.8
            # Refs:
            # * https://github.com/pytest-dev/pytest-xdist/issues/620
            # * https://stackoverflow.com/a/58614689/595220
            # * https://bugs.python.org/issue35621
            # * https://github.com/python/cpython/pull/14344
            watcher = asyncio.ThreadedChildWatcher()
        except AttributeError:  # Python < 3.8
            watcher = asyncio.SafeChildWatcher()
        watcher.attach_loop(loop)
        with contextlib.suppress(NotImplementedError):
            policy.set_child_watcher(watcher)
    return loop
Create and return an asyncio.BaseEventLoop instance.

    The caller should also call teardown_test_loop,
    once they are done with the loop.
    
lib/aiohttp/test_utils.py