Skip to content
Closed
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
Prev Previous commit
Next Next commit
Merge branch '3.8' into 3.8-revert-asynio-streams
  • Loading branch information
aeros authored Sep 28, 2019
commit 5460b602d158f20b04bb2627f050596138718420
39 changes: 11 additions & 28 deletions Lib/test/test_asyncio/test_streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ def test_read(self):
stream = asyncio.StreamReader(loop=self.loop,
_asyncio_internal=True)
read_task = asyncio.Task(stream.read(30), loop=self.loop)

def cb():
stream._feed_data(self.DATA)
self.loop.call_soon(cb)
Expand Down Expand Up @@ -203,7 +202,6 @@ def test_read_until_eof(self):
stream = asyncio.StreamReader(loop=self.loop,
_asyncio_internal=True)
read_task = asyncio.Task(stream.read(-1), loop=self.loop)

def cb():
stream._feed_data(b'chunk1\n')
stream._feed_data(b'chunk2')
Expand All @@ -219,7 +217,6 @@ def test_read_exception(self):
stream = asyncio.StreamReader(loop=self.loop,
_asyncio_internal=True)
stream.feed_data(b'line\n')

data = self.loop.run_until_complete(stream.read(2))
self.assertEqual(b'li', data)

Expand Down Expand Up @@ -252,6 +249,7 @@ def test_readline(self):
stream.feed_data(b'chunk1 ')
read_task = asyncio.Task(stream.readline(), loop=self.loop)


def cb():
stream._feed_data(b'chunk2 ')
stream._feed_data(b'chunk3 ')
Expand Down Expand Up @@ -343,6 +341,7 @@ def cb():
stream = asyncio.StreamReader(limit=7, loop=self.loop,
_asyncio_internal=True)
stream.feed_data(b'1234567\n')

line = self.loop.run_until_complete(stream.readline())
self.assertEqual(b'1234567\n', line)
self.assertEqual(b'', stream._buffer)
Expand All @@ -365,6 +364,7 @@ def test_readline_nolimit_nowait(self):
stream.feed_data(self.DATA[:6])
stream.feed_data(self.DATA[6:])


line = self.loop.run_until_complete(stream.readline())

self.assertEqual(b'line1\n', line)
Expand Down Expand Up @@ -392,6 +392,7 @@ def test_readline_read_byte_count(self):
_asyncio_internal=True)
stream.feed_data(self.DATA)


self.loop.run_until_complete(stream.readline())

data = self.loop.run_until_complete(stream.read(7))
Expand All @@ -404,6 +405,7 @@ def test_readline_exception(self):
_asyncio_internal=True)
stream.feed_data(b'line\n')


data = self.loop.run_until_complete(stream.readline())
self.assertEqual(b'line\n', data)

Expand Down Expand Up @@ -479,6 +481,7 @@ def test_readuntil_eof(self):
stream.feed_data(b'some dataAA')
stream.feed_eof()


with self.assertRaises(asyncio.IncompleteReadError) as cm:
self.loop.run_until_complete(stream.readuntil(b'AAA'))
self.assertEqual(cm.exception.partial, b'some dataAA')
Expand All @@ -490,6 +493,7 @@ def test_readuntil_limit_found_sep(self):
_asyncio_internal=True)
stream.feed_data(b'some dataAA')


with self.assertRaisesRegex(asyncio.LimitOverrunError,
'not found') as cm:
self.loop.run_until_complete(stream.readuntil(b'AAA'))
Expand All @@ -509,6 +513,7 @@ def test_readexactly_zero_or_less(self):
_asyncio_internal=True)
stream.feed_data(self.DATA)


data = self.loop.run_until_complete(stream.readexactly(0))
self.assertEqual(b'', data)
self.assertEqual(self.DATA, stream._buffer)
Expand Down Expand Up @@ -673,6 +678,7 @@ async def client(addr):
addr = server.start()
msg = self.loop.run_until_complete(asyncio.Task(client(addr),
loop=self.loop))

server.stop()
self.assertEqual(msg, b"hello world!\n")

Expand All @@ -681,6 +687,7 @@ async def client(addr):
addr = server.start_callback()
msg = self.loop.run_until_complete(asyncio.Task(client(addr),
loop=self.loop))

server.stop()
self.assertEqual(msg, b"hello world!\n")

Expand Down Expand Up @@ -1091,30 +1098,6 @@ def test_stream_writer_create_warning(self):
with self.assertWarns(DeprecationWarning):
asyncio.StreamWriter('transport', proto, reader, self.loop)

def test_deprecated_methods(self):
async def f():
return asyncio.Stream(mode=asyncio.StreamMode.READWRITE,
_asyncio_internal=True)

stream = self.loop.run_until_complete(f())

tr = mock.Mock()

with self.assertWarns(DeprecationWarning):
stream.set_transport(tr)

with self.assertWarns(DeprecationWarning):
stream.transport is tr

with self.assertWarns(DeprecationWarning):
stream.feed_data(b'data')

with self.assertWarns(DeprecationWarning):
stream.feed_eof()

with self.assertWarns(DeprecationWarning):
stream.set_exception(ConnectionResetError("test"))


if __name__ == '__main__':
unittest.main()
unittest.main()
You are viewing a condensed version of this merge commit. You can view the full changes here.