@@ -81,7 +81,8 @@ def test_check_hostname_accepts_server_hostname(self):
8181 # No ValueError is raised from SSLProtocol with 'server_hostname'.
8282 ssl_proto = sslproto .SSLProtocol (self .loop , app_proto , sslcontext , waiter ,
8383 server_hostname = 'example.org' )
84- self .addCleanup (ssl_proto ._app_transport .close )
84+ self .addCleanup (ssl_proto .connection_lost , None )
85+ ssl_proto .connection_made (mock .Mock ())
8586
8687 def test_check_hostname_requires_server_hostname (self ):
8788 # A caller-supplied context asking for hostname checking used to be
@@ -100,26 +101,32 @@ def test_check_hostname_requires_server_hostname(self):
100101 with self .assertWarnsRegex (
101102 DeprecationWarning ,
102103 'check_hostname requires server_hostname' ):
103- sslproto .SSLProtocol (self .loop , app_proto , sslcontext ,
104- waiter )
104+ ssl_proto = sslproto .SSLProtocol (
105+ self .loop , app_proto , sslcontext , waiter )
106+ self .addCleanup (ssl_proto .connection_lost , None )
107+ ssl_proto .connection_made (mock .Mock ())
105108
106109 with self .assertWarnsRegex (
107110 DeprecationWarning ,
108111 'check_hostname requires server_hostname' ):
109- sslproto .SSLProtocol (self .loop , app_proto , sslcontext ,
110- waiter ,
111- server_hostname = server_hostname )
112+ ssl_proto = sslproto .SSLProtocol (
113+ self .loop , app_proto , sslcontext , waiter ,
114+ server_hostname = server_hostname )
115+ self .addCleanup (ssl_proto .connection_lost , None )
116+ ssl_proto .connection_made (mock .Mock ())
112117
113118 # Disabling check_hostname allows for an empty or unset server_hostname.
114119 sslcontext .check_hostname = False
115120
116121 ssl_proto = sslproto .SSLProtocol (self .loop , app_proto , sslcontext , waiter )
117- self .addCleanup (ssl_proto ._app_transport .close )
122+ self .addCleanup (ssl_proto .connection_lost , None )
123+ ssl_proto .connection_made (mock .Mock ())
118124
119125 ssl_proto = sslproto .SSLProtocol (self .loop , app_proto , sslcontext ,
120126 waiter ,
121127 server_hostname = server_hostname )
122- self .addCleanup (ssl_proto ._app_transport .close )
128+ self .addCleanup (ssl_proto .connection_lost , None )
129+ ssl_proto .connection_made (mock .Mock ())
123130
124131 def test_eof_received_waiter (self ):
125132 waiter = self .loop .create_future ()
0 commit comments