]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.15] gh-151540: Use a selector event loop in the happy-eyeballs tests (GH-153375...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sat, 25 Jul 2026 03:23:02 +0000 (05:23 +0200)
committerGitHub <noreply@github.com>
Sat, 25 Jul 2026 03:23:02 +0000 (08:53 +0530)
gh-151540: Use a selector event loop in the happy-eyeballs tests (GH-153375)
(cherry picked from commit a1ef41ab4198db28f63fda646200b14badb96513)

Co-authored-by: Jakob Rossi <jmrossi98@gmail.com>
Lib/test/test_asyncio/test_base_events.py

index e59bc25668b4cba09d10edeae1d68c7347a36f7d..ffec37aaa6fe6bc12f27b31fa1c8c0831579e1b1 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()