Use WindowsSelectorEventLoopPolicy to fix Windows test warnings (#2607)

* fix: skip TextIO log file test on Windows

Avoids PytestUnraisableExceptionWarning caused by ProactorEventLoop
cleanup timing issues with subprocess pipe transports.

* Use WindowsSelectorEventLoopPolicy to fix Windows test warnings

Re-add the SelectorEventLoop fix from bcd2e594 that was inadvertently
removed in cf101c2a. This fixes ProactorEventLoop cleanup warnings
on Windows CI without needing to skip individual tests.
This commit is contained in:
Jeremiah Lowin 2025-12-14 08:39:44 -05:00 committed by GitHub
commit 08d092be57
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,4 +1,6 @@
import asyncio
import socket
import sys
from collections.abc import Callable
from pathlib import Path
from typing import Any
@ -7,6 +9,11 @@ import pytest
from fastmcp.utilities.tests import temporary_settings
# Use SelectorEventLoop on Windows to avoid ProactorEventLoop crashes
# See: https://github.com/python/cpython/issues/116773
if sys.platform == "win32":
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
def pytest_collection_modifyitems(items):
"""Automatically mark tests in integration_tests folder with 'integration' marker."""