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

Appearance settings

gh-93357: Port test cases to IsolatedAsyncioTestCase, part 2 #97896

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
Port test cases to IsolatedAsyncioTestCase, part 2
  • Loading branch information
arhadthedev authored Oct 5, 2022
commit 79505dffe223bd32f6076b93ad2f229e7960a235
16 changes: 8 additions & 8 deletions 16 Lib/test/test_asyncio/test_streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,7 @@ 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):
async with test_utils.run_test_server() as httpd:
rd, wr = self.loop.run_until_complete(
Expand All @@ -956,19 +957,18 @@ async def test_wait_closed_on_close(self):
self.assertTrue(wr.is_closing())
await wr.wait_closed()

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

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

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

Expand All @@ -984,11 +984,11 @@ async def inner(httpd):
self.loop.set_exception_handler(lambda loop, ctx: messages.append(ctx))

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

self.assertEqual(messages, [])

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

Expand All @@ -1006,7 +1006,7 @@ async def inner(httpd):
self.loop.set_exception_handler(lambda loop, ctx: messages.append(ctx))

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

self.assertEqual(messages, [])

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.