mirror of
https://github.com/python/cpython.git
synced 2025-09-20 15:40:32 +00:00
asyncio: Sync with github
This commit is contained in:
parent
5e58600c42
commit
dddc781998
2 changed files with 5 additions and 2 deletions
|
@ -494,6 +494,9 @@ class StreamReader:
|
||||||
|
|
||||||
@coroutine
|
@coroutine
|
||||||
def readexactly(self, n):
|
def readexactly(self, n):
|
||||||
|
if n < 0:
|
||||||
|
raise ValueError('readexactly size can not be less than zero')
|
||||||
|
|
||||||
if self._exception is not None:
|
if self._exception is not None:
|
||||||
raise self._exception
|
raise self._exception
|
||||||
|
|
||||||
|
|
|
@ -351,8 +351,8 @@ class StreamReaderTests(test_utils.TestCase):
|
||||||
self.assertEqual(b'', data)
|
self.assertEqual(b'', data)
|
||||||
self.assertEqual(self.DATA, stream._buffer)
|
self.assertEqual(self.DATA, stream._buffer)
|
||||||
|
|
||||||
data = self.loop.run_until_complete(stream.readexactly(-1))
|
with self.assertRaisesRegexp(ValueError, 'less than zero'):
|
||||||
self.assertEqual(b'', data)
|
self.loop.run_until_complete(stream.readexactly(-1))
|
||||||
self.assertEqual(self.DATA, stream._buffer)
|
self.assertEqual(self.DATA, stream._buffer)
|
||||||
|
|
||||||
def test_readexactly(self):
|
def test_readexactly(self):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue