@@ -941,32 +941,34 @@ def test_LimitOverrunError_pickleable(self):
941941 self .assertEqual (str (e ), str (e2 ))
942942 self .assertEqual (e .consumed , e2 .consumed )
943943
944- class NewStreamTests2 (unittest .IsolatedAsyncioTestCase ):
945944 async def test_wait_closed_on_close (self ):
946- with test_utils .run_test_server () as httpd :
947- rd , wr = await asyncio .open_connection (* httpd .address )
945+ async with test_utils .run_test_server () as httpd :
946+ rd , wr = self .loop .run_until_complete (
947+ asyncio .open_connection (* httpd .address ))
948948
949949 wr .write (b'GET / HTTP/1.0\r \n \r \n ' )
950950 data = await rd .readline ()
951951 self .assertEqual (data , b'HTTP/1.0 200 OK\r \n ' )
952- data = await rd .read ()
952+ await rd .read ()
953953 self .assertTrue (data .endswith (b'\r \n \r \n Test message' ))
954954 self .assertFalse (wr .is_closing ())
955955 wr .close ()
956956 self .assertTrue (wr .is_closing ())
957957 await wr .wait_closed ()
958958
959- async def test_wait_closed_on_close_with_unread_data (self ):
959+ def test_wait_closed_on_close_with_unread_data (self ):
960960 with test_utils .run_test_server () as httpd :
961- rd , wr = await asyncio .open_connection (* httpd .address )
961+ rd , wr = self .loop .run_until_complete (
962+ asyncio .open_connection (* httpd .address ))
962963
963964 wr .write (b'GET / HTTP/1.0\r \n \r \n ' )
964- data = await rd .readline ()
965+ f = rd .readline ()
966+ data = self .loop .run_until_complete (f )
965967 self .assertEqual (data , b'HTTP/1.0 200 OK\r \n ' )
966968 wr .close ()
967- await wr .wait_closed ()
969+ self . loop . run_until_complete ( wr .wait_closed () )
968970
969- async def test_async_writer_api (self ):
971+ def test_async_writer_api (self ):
970972 async def inner (httpd ):
971973 rd , wr = await asyncio .open_connection (* httpd .address )
972974
@@ -978,10 +980,15 @@ async def inner(httpd):
978980 wr .close ()
979981 await wr .wait_closed ()
980982
983+ messages = []
984+ self .loop .set_exception_handler (lambda loop , ctx : messages .append (ctx ))
985+
981986 with test_utils .run_test_server () as httpd :
982- await inner (httpd )
987+ self .loop .run_until_complete (inner (httpd ))
988+
989+ self .assertEqual (messages , [])
983990
984- async def test_async_writer_api_exception_after_close (self ):
991+ def test_async_writer_api_exception_after_close (self ):
985992 async def inner (httpd ):
986993 rd , wr = await asyncio .open_connection (* httpd .address )
987994
@@ -995,17 +1002,24 @@ async def inner(httpd):
9951002 wr .write (b'data' )
9961003 await wr .drain ()
9971004
1005+ messages = []
1006+ self .loop .set_exception_handler (lambda loop , ctx : messages .append (ctx ))
1007+
9981008 with test_utils .run_test_server () as httpd :
999- await inner (httpd )
1009+ self .loop .run_until_complete (inner (httpd ))
1010+
1011+ self .assertEqual (messages , [])
10001012
10011013 async def test_eof_feed_when_closing_writer (self ):
10021014 # See http://bugs.python.org/issue35065
1003- with test_utils .run_test_server () as httpd :
1015+ async with test_utils .run_test_server () as httpd :
10041016 rd , wr = await asyncio .open_connection (* httpd .address )
10051017 wr .close ()
1006- await wr .wait_closed ()
1018+ f = wr .wait_closed ()
1019+ self .loop .run_until_complete (f )
10071020 self .assertTrue (rd .at_eof ())
1008- data = await rd .read ()
1021+ f = rd .read ()
1022+ data = self .loop .run_until_complete (f )
10091023 self .assertEqual (data , b'' )
10101024
10111025
0 commit comments