@@ -221,17 +221,17 @@ def test_create_unix_server_existing_path_sock(self):
221221 with test_utils .unix_socket_path () as path :
222222 sock = socket .socket (socket .AF_UNIX )
223223 sock .bind (path )
224-
225- coro = self .loop .create_unix_server (lambda : None , path )
226- with self .assertRaisesRegexp (OSError ,
227- 'Address.*is already in use' ):
228- self .loop .run_until_complete (coro )
224+ with sock :
225+ coro = self .loop .create_unix_server (lambda : None , path )
226+ with self .assertRaisesRegex (OSError ,
227+ 'Address.*is already in use' ):
228+ self .loop .run_until_complete (coro )
229229
230230 def test_create_unix_server_existing_path_nonsock (self ):
231231 with tempfile .NamedTemporaryFile () as file :
232232 coro = self .loop .create_unix_server (lambda : None , file .name )
233- with self .assertRaisesRegexp (OSError ,
234- 'Address.*is already in use' ):
233+ with self .assertRaisesRegex (OSError ,
234+ 'Address.*is already in use' ):
235235 self .loop .run_until_complete (coro )
236236
237237 def test_create_unix_server_ssl_bool (self ):
@@ -248,11 +248,13 @@ def test_create_unix_server_nopath_nosock(self):
248248 self .loop .run_until_complete (coro )
249249
250250 def test_create_unix_server_path_inetsock (self ):
251- coro = self .loop .create_unix_server (lambda : None , path = None ,
252- sock = socket .socket ())
253- with self .assertRaisesRegex (ValueError ,
254- 'A UNIX Domain Socket was expected' ):
255- self .loop .run_until_complete (coro )
251+ sock = socket .socket ()
252+ with sock :
253+ coro = self .loop .create_unix_server (lambda : None , path = None ,
254+ sock = sock )
255+ with self .assertRaisesRegex (ValueError ,
256+ 'A UNIX Domain Socket was expected' ):
257+ self .loop .run_until_complete (coro )
256258
257259 def test_create_unix_connection_path_sock (self ):
258260 coro = self .loop .create_unix_connection (
@@ -278,7 +280,7 @@ def test_create_unix_connection_ssl_noserverhost(self):
278280 coro = self .loop .create_unix_connection (
279281 lambda : None , '/dev/null' , ssl = True )
280282
281- with self .assertRaisesRegexp (
283+ with self .assertRaisesRegex (
282284 ValueError , 'you have to pass server_hostname when using ssl' ):
283285
284286 self .loop .run_until_complete (coro )
0 commit comments