Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit09aea94

Browse files
authored
gh-93357: Port test cases to IsolatedAsyncioTestCase, part 2 (#97896)
This fixes the buildbots.
1 parent77f0249 commit09aea94

File tree

1 file changed

+15
-29
lines changed

1 file changed

+15
-29
lines changed

‎Lib/test/test_asyncio/test_streams.py

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -941,34 +941,32 @@ def test_LimitOverrunError_pickleable(self):
941941
self.assertEqual(str(e),str(e2))
942942
self.assertEqual(e.consumed,e2.consumed)
943943

944+
classNewStreamTests2(unittest.IsolatedAsyncioTestCase):
944945
asyncdeftest_wait_closed_on_close(self):
945-
asyncwithtest_utils.run_test_server()ashttpd:
946-
rd,wr=self.loop.run_until_complete(
947-
asyncio.open_connection(*httpd.address))
946+
withtest_utils.run_test_server()ashttpd:
947+
rd,wr=awaitasyncio.open_connection(*httpd.address)
948948

949949
wr.write(b'GET / HTTP/1.0\r\n\r\n')
950950
data=awaitrd.readline()
951951
self.assertEqual(data,b'HTTP/1.0 200 OK\r\n')
952-
awaitrd.read()
952+
data=awaitrd.read()
953953
self.assertTrue(data.endswith(b'\r\n\r\nTest message'))
954954
self.assertFalse(wr.is_closing())
955955
wr.close()
956956
self.assertTrue(wr.is_closing())
957957
awaitwr.wait_closed()
958958

959-
deftest_wait_closed_on_close_with_unread_data(self):
959+
asyncdeftest_wait_closed_on_close_with_unread_data(self):
960960
withtest_utils.run_test_server()ashttpd:
961-
rd,wr=self.loop.run_until_complete(
962-
asyncio.open_connection(*httpd.address))
961+
rd,wr=awaitasyncio.open_connection(*httpd.address)
963962

964963
wr.write(b'GET / HTTP/1.0\r\n\r\n')
965-
f=rd.readline()
966-
data=self.loop.run_until_complete(f)
964+
data=awaitrd.readline()
967965
self.assertEqual(data,b'HTTP/1.0 200 OK\r\n')
968966
wr.close()
969-
self.loop.run_until_complete(wr.wait_closed())
967+
awaitwr.wait_closed()
970968

971-
deftest_async_writer_api(self):
969+
asyncdeftest_async_writer_api(self):
972970
asyncdefinner(httpd):
973971
rd,wr=awaitasyncio.open_connection(*httpd.address)
974972

@@ -980,15 +978,10 @@ async def inner(httpd):
980978
wr.close()
981979
awaitwr.wait_closed()
982980

983-
messages= []
984-
self.loop.set_exception_handler(lambdaloop,ctx:messages.append(ctx))
985-
986981
withtest_utils.run_test_server()ashttpd:
987-
self.loop.run_until_complete(inner(httpd))
988-
989-
self.assertEqual(messages, [])
982+
awaitinner(httpd)
990983

991-
deftest_async_writer_api_exception_after_close(self):
984+
asyncdeftest_async_writer_api_exception_after_close(self):
992985
asyncdefinner(httpd):
993986
rd,wr=awaitasyncio.open_connection(*httpd.address)
994987

@@ -1002,24 +995,17 @@ async def inner(httpd):
1002995
wr.write(b'data')
1003996
awaitwr.drain()
1004997

1005-
messages= []
1006-
self.loop.set_exception_handler(lambdaloop,ctx:messages.append(ctx))
1007-
1008998
withtest_utils.run_test_server()ashttpd:
1009-
self.loop.run_until_complete(inner(httpd))
1010-
1011-
self.assertEqual(messages, [])
999+
awaitinner(httpd)
10121000

10131001
asyncdeftest_eof_feed_when_closing_writer(self):
10141002
# See http://bugs.python.org/issue35065
1015-
asyncwithtest_utils.run_test_server()ashttpd:
1003+
withtest_utils.run_test_server()ashttpd:
10161004
rd,wr=awaitasyncio.open_connection(*httpd.address)
10171005
wr.close()
1018-
f=wr.wait_closed()
1019-
self.loop.run_until_complete(f)
1006+
awaitwr.wait_closed()
10201007
self.assertTrue(rd.at_eof())
1021-
f=rd.read()
1022-
data=self.loop.run_until_complete(f)
1008+
data=awaitrd.read()
10231009
self.assertEqual(data,b'')
10241010

10251011

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp