diff options
| author | Yury Selivanov <yselivanov@sprymix.com> | 2015-05-13 18:23:29 (GMT) |
|---|---|---|
| committer | Yury Selivanov <yselivanov@sprymix.com> | 2015-05-13 18:23:29 (GMT) |
| commit | 33c6b569b7b123976230c92c6d8e74b2c10fef2e (patch) | |
| tree | fe2ad5b421ed45a15afdabd81ffc4395121c3bfa /Lib/test/test_asyncio/test_pep492.py | |
| parent | d4be6914943fbc829bcbb62c3aa59f84c917c522 (diff) | |
| download | cpython-33c6b569b7b123976230c92c6d8e74b2c10fef2e.zip cpython-33c6b569b7b123976230c92c6d8e74b2c10fef2e.tar.gz cpython-33c6b569b7b123976230c92c6d8e74b2c10fef2e.tar.bz2 | |
Issue 24179: Support 'async for' for asyncio.StreamReader.
Diffstat (limited to 'Lib/test/test_asyncio/test_pep492.py')
| -rw-r--r-- | Lib/test/test_asyncio/test_pep492.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/test/test_asyncio/test_pep492.py b/Lib/test/test_asyncio/test_pep492.py index c9a2f96..3d8d1b8 100644 --- a/Lib/test/test_asyncio/test_pep492.py +++ b/Lib/test/test_asyncio/test_pep492.py @@ -64,5 +64,24 @@ class LockTests(BaseTest): self.assertFalse(primitive.locked()) +class StreamReaderTests(BaseTest): + + def test_readline(self): + DATA = b'line1\nline2\nline3' + + stream = asyncio.StreamReader(loop=self.loop) + stream.feed_data(DATA) + stream.feed_eof() + + async def reader(): + data = [] + async for line in stream: + data.append(line) + return data + + data = self.loop.run_until_complete(reader()) + self.assertEqual(data, [b'line1\n', b'line2\n', b'line3']) + + if __name__ == '__main__': unittest.main() |
