Skip to content

Commit d4b2c8c

Browse files
committed
Use correct event loop primitive for test in sslproto
1 parent 9b5f9c8 commit d4b2c8c

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Lib/test/test_asyncio/test_sslproto.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
from asyncio import log
1717
from asyncio import protocols
1818
from asyncio import sslproto
19-
from asyncio import selector_events
2019
from test.test_asyncio import utils as test_utils
2120
from test.test_asyncio import functional as func_tests
2221

@@ -111,12 +110,14 @@ def test_connection_lost(self):
111110
self.assertIsInstance(waiter.exception(), ConnectionAbortedError)
112111

113112
def test_connection_lost_when_busy(self):
113+
# gh-118950: SSLProtocol.connection_lost not being called when OSError
114+
# is thrown on asyncio.write.
114115
sock = mock.Mock()
115116
sock.fileno = mock.Mock(return_value=12345)
116117
sock.send = mock.Mock(side_effect=BrokenPipeError)
117118

118-
# construct StreamWriter chain that contains loop dependant logic this emulates that
119-
# _make_ssl_transport() does in BaseSelectorEventLoop
119+
# construct StreamWriter chain that contains loop dependant logic this emulates
120+
# what _make_ssl_transport() does in BaseSelectorEventLoop
120121
reader = asyncio.StreamReader(limit=2 ** 16, loop=self.loop)
121122
protocol = asyncio.StreamReaderProtocol(reader, loop=self.loop)
122123
ssl_proto = self.ssl_protocol(proto=protocol)
@@ -136,7 +137,8 @@ def test_connection_lost_when_busy(self):
136137
ssl_proto._outgoing = outgoing
137138

138139
# use correct socket transport to initialize the SSLProtocol
139-
selector_events._SelectorSocketTransport(self.loop, sock, ssl_proto)
140+
self.loop._make_socket_transport(sock, ssl_proto)
141+
140142
transport = ssl_proto._app_transport
141143
writer = asyncio.StreamWriter(transport, protocol, reader, self.loop)
142144

0 commit comments

Comments
 (0)