]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-151540: Use a selector event loop in the happy-eyeballs tests (#153375)
authorJakob Rossi <jmrossi98@gmail.com>
Sat, 11 Jul 2026 07:17:42 +0000 (03:17 -0400)
committerGitHub <noreply@github.com>
Sat, 11 Jul 2026 07:17:42 +0000 (12:47 +0530)
Lib/test/test_asyncio/test_base_events.py

index b4fd7abed5963ea622f8d18bba519f9c25da385b..1622f19f0213f3c840b68d3aea1d4b9be565c411 100644 (file)
@@ -1092,7 +1092,11 @@ class BaseEventLoopTests(test_utils.TestCase):
                 await asyncio.sleep(1)
             sock.connect(address)
 
-        loop = asyncio.new_event_loop()
+        # gh-151540: use a selector event loop instead of the platform
+        # default; the Windows proactor loop would register the mocked
+        # socket with a real IOCP handle instead of the mocked
+        # _add_reader/_add_writer below.
+        loop = asyncio.SelectorEventLoop()
         loop._add_writer = mock.Mock()
         loop._add_writer = mock.Mock()
         loop._add_reader = mock.Mock()
@@ -1124,7 +1128,8 @@ class BaseEventLoopTests(test_utils.TestCase):
                 await asyncio.sleep(1)
             sock.connect(address)
 
-        loop = asyncio.new_event_loop()
+        # gh-151540: see test_create_connection_happy_eyeballs above.
+        loop = asyncio.SelectorEventLoop()
         loop._add_writer = mock.Mock()
         loop._add_writer = mock.Mock()
         loop._add_reader = mock.Mock()