@@ -423,9 +423,10 @@ def test_create_unix_connection_6(self):
423423
424424 def test_create_unix_connection_sock_cancel_detaches (self ):
425425 async def test ():
426- srv_path = os .path .join (tempfile .mkdtemp (), ' test.sock' )
426+ srv_path = os .path .join (tempfile .mkdtemp (), " test.sock" )
427427 srv = await asyncio .start_unix_server (
428- lambda r , w : w .close (), path = srv_path )
428+ lambda r , w : w .close (), path = srv_path
429+ )
429430
430431 sock = socket .socket (socket .AF_UNIX , socket .SOCK_STREAM )
431432 sock .setblocking (False )
@@ -436,8 +437,8 @@ async def test():
436437 await asyncio .sleep (0.01 )
437438
438439 task = asyncio .ensure_future (
439- self .loop .create_unix_connection (
440- asyncio . Protocol , sock = sock ) )
440+ self .loop .create_unix_connection (asyncio . Protocol , sock = sock )
441+ )
441442 await asyncio .sleep (0 )
442443 task .cancel ()
443444 with self .assertRaises (asyncio .CancelledError ):
@@ -457,18 +458,19 @@ def test_create_unix_connection_sock_cancel_fd_leak(self):
457458 # the create_unix_connection(sock=) path.
458459
459460 async def test ():
460- srv_path = os .path .join (tempfile .mkdtemp (), ' test.sock' )
461+ srv_path = os .path .join (tempfile .mkdtemp (), " test.sock" )
461462 srv = await asyncio .start_unix_server (
462- lambda r , w : w .close (), path = srv_path )
463+ lambda r , w : w .close (), path = srv_path
464+ )
463465
464466 sock = socket .socket (socket .AF_UNIX , socket .SOCK_STREAM )
465467 sock .setblocking (False )
466468 await self .loop .sock_connect (sock , srv_path )
467469 stale_fd = sock .fileno ()
468470
469471 task = self .loop .create_task (
470- self .loop .create_unix_connection (
471- asyncio . Protocol , sock = sock ) )
472+ self .loop .create_unix_connection (asyncio . Protocol , sock = sock )
473+ )
472474 await asyncio .sleep (0 )
473475 task .cancel ()
474476 with self .assertRaises (asyncio .CancelledError ):
@@ -479,8 +481,9 @@ async def test():
479481 victim_sock .setblocking (False )
480482 await self .loop .sock_connect (victim_sock , srv_path )
481483 victim_tr , _ = await self .loop .create_unix_connection (
482- asyncio .Protocol , sock = victim_sock )
483- victim_fd = victim_tr .get_extra_info ('socket' ).fileno ()
484+ asyncio .Protocol , sock = victim_sock
485+ )
486+ victim_fd = victim_tr .get_extra_info ("socket" ).fileno ()
484487 if victim_fd != stale_fd :
485488 victim_tr .close ()
486489 sock .close ()
@@ -489,7 +492,8 @@ async def test():
489492 if os .path .exists (srv_path ):
490493 os .unlink (srv_path )
491494 raise unittest .SkipTest (
492- f'fd not reused (got { victim_fd } , need { stale_fd } )' )
495+ f"fd not reused (got { victim_fd } , need { stale_fd } )"
496+ )
493497
494498 spy_a , spy_b = socket .socketpair ()
495499 spy_b .setblocking (False )
@@ -506,12 +510,12 @@ async def test():
506510 os .dup2 (spy_a .fileno (), stale_fd )
507511 spy_a .close ()
508512
509- victim_tr .write (b' LEAKED' )
513+ victim_tr .write (b" LEAKED" )
510514
511515 try :
512516 leaked = spy_b .recv (4096 )
513517 except BlockingIOError :
514- leaked = b''
518+ leaked = b""
515519
516520 if victim_broken :
517521 os .close (stale_fd )
@@ -526,9 +530,11 @@ async def test():
526530 if os .path .exists (srv_path ):
527531 os .unlink (srv_path )
528532
529- self .assertEqual (leaked , b'' ,
530- f"Data leaked to an unrelated socket: "
531- f"got { leaked !r} " )
533+ self .assertEqual (
534+ leaked ,
535+ b"" ,
536+ f"Data leaked to an unrelated socket: " f"got { leaked !r} " ,
537+ )
532538
533539 self .loop .run_until_complete (test ())
534540
0 commit comments