@@ -347,23 +347,22 @@ def connection_lost(self, exc):
347347
348348 async def run ():
349349 transport , _ = await self .loop .connect_read_pipe (Proto , pipe )
350- await lost
350+ exc = await lost
351351 transport .close ()
352+ return exc
352353
353- self .loop .run_until_complete (run ())
354- self .assertTrue (self .errors , 'no error reached the exception handler' )
355- self .assertIsInstance (self .errors [0 ]['exception' ], OSError )
354+ exc = self .loop .run_until_complete (run ())
355+ self .assertIsInstance (exc , OSError )
356356
357357 def check_write_rejected (self , pipe ):
358358 self .addCleanup (pipe .close )
359359 with self .assertRaises (OSError ):
360360 self .loop .run_until_complete (
361361 self .loop .connect_write_pipe (asyncio .BaseProtocol , pipe ))
362362
363- def test_overlapped_pipe (self ):
364- rhandle , whandle = windows_utils .pipe (overlapped = (True , True ))
365- rpipe = windows_utils .PipeHandle (rhandle )
366- wpipe = windows_utils .PipeHandle (whandle )
363+ def check_accepted (self , rpipe , wpipe ):
364+ self .addCleanup (rpipe .close )
365+ self .addCleanup (wpipe .close )
367366
368367 chunks = []
369368 lost = self .loop .create_future ()
@@ -389,6 +388,15 @@ async def run():
389388 self .assertEqual (b'' .join (chunks ), b'spam' )
390389 self .assertFalse (self .errors )
391390
391+ def test_overlapped_pipe (self ):
392+ rhandle , whandle = windows_utils .pipe (duplex = True , overlapped = (True , True ))
393+ self .check_accepted (windows_utils .PipeHandle (rhandle ),
394+ windows_utils .PipeHandle (whandle ))
395+
396+ def test_socketpair (self ):
397+ rsock , wsock = socket .socketpair ()
398+ self .check_accepted (rsock , wsock )
399+
392400 def test_read_non_overlapped_pipe (self ):
393401 rhandle , whandle = windows_utils .pipe (overlapped = (False , False ))
394402 self .addCleanup (windows_utils .PipeHandle (whandle ).close )
@@ -409,6 +417,16 @@ def test_write_regular_file(self):
409417 self .addCleanup (os_helper .unlink , os_helper .TESTFN )
410418 self .check_write_rejected (open (os_helper .TESTFN , 'wb' , 0 ))
411419
420+ def test_read_os_pipe (self ):
421+ rfd , wfd = os .pipe ()
422+ self .addCleanup (os .close , wfd )
423+ self .check_read_rejected (open (rfd , 'rb' , 0 ))
424+
425+ def test_write_os_pipe (self ):
426+ rfd , wfd = os .pipe ()
427+ self .addCleanup (os .close , rfd )
428+ self .check_write_rejected (open (wfd , 'wb' , 0 ))
429+
412430
413431if __name__ == '__main__' :
414432 unittest .main ()
0 commit comments