8000 gh-97983: Revert "Lay the foundation for further work in asyncio.test_streams: port server cases to IsolatedAsyncioTestCase" by arhadthedev · Pull Request #98015 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-97983: Revert "Lay the foundation for further work in asyncio.test_streams: port server cases to IsolatedAsyncioTestCase" #98015

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Revert "gh-93357: Port test cases to IsolatedAsyncioTestCase, part 2 (#…
…97896)"

This reverts commit 09aea94.
  • Loading branch information
arhadthedev committed Oct 7, 2022
commit 3713915405f5b98b3ca929f65043a06f6d497aa1
44 changes: 29 additions & 15 deletions Lib/test/test_asyncio/test_streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -941,32 +941,34 @@ def test_LimitOverrunError_pickleable(self):
self.assertEqual(str(e), str(e2))
self.assertEqual(e.consumed, e2.consumed)

class NewStreamTests2(unittest.IsolatedAsyncioTestCase):
async def test_wait_closed_on_close(self):
with test_utils.run_test_server() as httpd:
rd, wr = await asyncio.open_connection(*httpd.address)
async with test_utils.run_test_server() as httpd:
rd, wr = self.loop.run_until_complete(
asyncio.open_connection(*httpd.address))

wr.write(b'GET / HTTP/1.0\r\n\r\n')
data = await rd.readline()
self.assertEqual(data, b'HTTP/1.0 200 OK\r\n')
data = await rd.read()
await rd.read()
self.assertTrue(data.endswith(b'\r\n\r\nTest message'))
self.assertFalse(wr.is_closing())
wr.close()
self.assertTrue(wr.is_closing())
await wr.wait_closed()

async def test_wait_closed_on_close_with_unread_data(self):
def test_wait_closed_on_close_with_unread_data(self):
with test_utils.run_test_server() as httpd:
rd, wr = await asyncio.open_connection(*httpd.address)
rd, wr = self.loop.run_until_complete(
asyncio.open_connection(*httpd.address))

wr.write(b'GET / HTTP/1.0\r\n\r\n')
data = await rd.readline()
f = rd.readline()
data = self.loop.run_until_complete(f)
self.assertEqual(data, b'HTTP/1.0 200 OK\r\n')
wr.close()
await wr.wait_closed()
self.loop.run_until_complete(wr.wait_closed())

async def test_async_writer_api(self):
def test_async_writer_api(self):
async def inner(httpd):
rd, wr = await asyncio.open_connection(*httpd.address)

Expand All @@ -978,10 +980,15 @@ async def inner(httpd):
wr.close()
await wr.wait_closed()

messages = []
self.loop.set_exception_handler(lambda loop, ctx: messages.append(ctx))

with test_utils.run_test_server() as httpd:
await inner(httpd)
self.loop.run_until_complete(inner(httpd))

self.assertEqual(messages, [])

async def test_async_writer_api_exception_after_close(self):
def test_async_writer_api_exception_after_close(self):
async def inner(httpd):
rd, wr = await asyncio.open_connection(*httpd.address)

Expand All @@ -995,17 +1002,24 @@ async def inner(httpd):
wr.write(b'data')
await wr.drain()

messages = []
self.loop.set_exception_handler(lambda loop, ctx: messages.append(ctx))

with test_utils.run_test_server() as httpd:
await inner(httpd)
self.loop.run_until_complete(inner(httpd))

self.assertEqual(messages, [])

async def test_eof_feed_when_closing_writer(self):
# See http://bugs.python.org/issue35065
with test_utils.run_test_server() as httpd:
async with test_utils.run_test_server() as httpd:
rd, wr = await asyncio.open_connection(*httpd.address)
wr.close()
await wr.wait_closed()
f = wr.wait_closed()
self.loop.run_until_complete(f)
self.assertTrue(rd.at_eof())
data = await rd.read()
f = rd.read()
data = self.loop.run_until_complete(f)
self.assertEqual(data, b'')


Expand Down
0