@@ -941,32 +941,34 @@ def test_LimitOverrunError_pickleable(self):
941
941
self .assertEqual (str (e ), str (e2 ))
942
942
self .assertEqual (e .consumed , e2 .consumed )
943
943
944
- class NewStreamTests2 (unittest .IsolatedAsyncioTestCase ):
945
944
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 ))
948
948
949
949
wr .write (b'GET / HTTP/1.0\r \n \r \n ' )
950
950
data = await rd .readline ()
951
951
self .assertEqual (data , b'HTTP/1.0 200 OK\r \n ' )
952
- data = await rd .read ()
952
+ await rd .read ()
953
953
self .assertTrue (data .endswith (b'\r \n \r \n Test message' ))
954
954
self .assertFalse (wr .is_closing ())
955
955
wr .close ()
956
956
self .assertTrue (wr .is_closing ())
957
957
await wr .wait_closed ()
958
958
959
- async def test_wait_closed_on_close_with_unread_data (self ):
959
+ def test_wait_closed_on_close_with_unread_data (self ):
960
960
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 ))
962
963
963
964
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 )
965
967
self .assertEqual (data , b'HTTP/1.0 200 OK\r \n ' )
966
968
wr .close ()
967
- await wr .wait_closed ()
969
+ self . loop . run_until_complete ( wr .wait_closed () )
968
970
969
- async def test_async_writer_api (self ):
971
+ def test_async_writer_api (self ):
970
972
async def inner (httpd ):
971
973
rd , wr = await asyncio .open_connection (* httpd .address )
972
974
@@ -978,10 +980,15 @@ async def inner(httpd):
978
980
wr .close ()
979
981
await wr .wait_closed ()
980
982
983
+ messages = []
984
+ self .loop .set_exception_handler (lambda loop , ctx : messages .append (ctx ))
985
+
981
986
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 , [])
983
990
984
- async def test_async_writer_api_exception_after_close (self ):
991
+ def test_async_writer_api_exception_after_close (self ):
985
992
async def inner (httpd ):
986
993
rd , wr = await asyncio .open_connection (* httpd .address )
987
994
@@ -995,17 +1002,24 @@ async def inner(httpd):
995
1002
wr .write (b'data' )
996
1003
await wr .drain ()
997
1004
1005
+ messages = []
1006
+ self .loop .set_exception_handler (lambda loop , ctx : messages .append (ctx ))
1007
+
998
1008
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 , [])
1000
1012
1001
1013
async def test_eof_feed_when_closing_writer (self ):
1002
1014
# 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 :
1004
1016
rd , wr = await asyncio .open_connection (* httpd .address )
1005
1017
wr .close ()
1006
- await wr .wait_closed ()
1018
+ f = wr .wait_closed ()
1019
+ self .loop .run_until_complete (f )
1007
1020
self .assertTrue (rd .at_eof ())
1008
- data = await rd .read ()
1021
+ f = rd .read ()
1022
+ data = self .loop .run_until_complete (f )
1009
1023
self .assertEqual (data , b'' )
1010
1024
1011
1025
0 commit comments