mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
asyncio.streams.StreamReader: Add 'at_eof()' method
This commit is contained in:
parent
e694c9745f
commit
f0020f5d77
2 changed files with 19 additions and 0 deletions
|
@ -204,6 +204,21 @@ class StreamReaderTests(unittest.TestCase):
|
|||
# expected to be empty now.
|
||||
self.assertEqual(b'', stream._buffer)
|
||||
|
||||
def test_at_eof(self):
|
||||
stream = asyncio.StreamReader(loop=self.loop)
|
||||
self.assertFalse(stream.at_eof())
|
||||
|
||||
stream.feed_data(b'some data\n')
|
||||
self.assertFalse(stream.at_eof())
|
||||
|
||||
self.loop.run_until_complete(stream.readline())
|
||||
self.assertFalse(stream.at_eof())
|
||||
|
||||
stream.feed_data(b'some data\n')
|
||||
stream.feed_eof()
|
||||
self.loop.run_until_complete(stream.readline())
|
||||
self.assertTrue(stream.at_eof())
|
||||
|
||||
def test_readline_limit(self):
|
||||
# Read one line. StreamReaders are fed with data after
|
||||
# their 'readline' methods are called.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue