@@ -751,14 +751,15 @@ async def test_urlencoded_formdata_charset(loop, conn) -> None:
751751 data = aiohttp .FormData ({"hey" : "you" }, charset = "koi8-r" ),
752752 loop = loop ,
753753 )
754- await req .send (conn )
754+ async with await req .send (conn ):
755+ await asyncio .sleep (0 )
755756 assert "application/x-www-form-urlencoded; charset=koi8-r" == req .headers .get (
756757 "CONTENT-TYPE"
757758 )
758759 await req .close ()
759760
760761
761- async def test_post_data (loop , conn ) -> None :
762+ async def test_post_data (loop : asyncio . AbstractEventLoop , conn : mock . Mock ) -> None :
762763 for meth in ClientRequest .POST_METHODS :
763764 req = ClientRequest (
764765 meth , URL ("http://python.org/" ), data = {"life" : "42" }, loop = loop
@@ -1087,10 +1088,12 @@ async def throw_exc():
10871088
10881089 loop .create_task (throw_exc ())
10891090
1090- await req .send (conn )
1091- await req ._writer
1092- # assert conn.close.called
1093- assert conn .protocol .set_exception .called
1091+ async with await req .send (conn ):
1092+ assert req ._writer is not None
1093+ await req ._writer
1094+ # assert conn.close.called
1095+ assert conn .protocol is not None
1096+ assert conn .protocol .set_exception .called
10941097 await req .close ()
10951098
10961099
@@ -1112,9 +1115,10 @@ async def throw_exc():
11121115
11131116 loop .create_task (throw_exc ())
11141117
1115- await req .send (conn )
1116- await req ._writer
1117- # assert connection.close.called
1118+ async with await req .send (conn ):
1119+ assert req ._writer is not None
1120+ await req ._writer
1121+ # assert conn.close.called
11181122 assert conn .protocol .set_exception .called
11191123 outer_exc = conn .protocol .set_exception .call_args [0 ][0 ]
11201124 assert isinstance (outer_exc , ClientConnectionError )
0 commit comments