Skip to content

Commit

Permalink
Fix incorrect warning in StreamReader.
Browse files Browse the repository at this point in the history
  • Loading branch information
Yegor Roganov committed Sep 7, 2017
1 parent 60f3342 commit 5fce093
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions aiohttp/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ def unread_data(self, data):
self._buffer_offset = 0
self._size += len(data)
self._buffer.appendleft(data)
self._eof_counter = 0

def feed_data(self, data):
assert not self._eof, 'feed_data after feed_eof'
Expand Down
1 change: 1 addition & 0 deletions changes/dummy.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix incorrect warning in StreamReader.
16 changes: 16 additions & 0 deletions tests/test_streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,22 @@ def test_read_eof_infinit(self, internal_logger):
self.loop.run_until_complete(stream.read())
self.assertTrue(internal_logger.warning.called)

@mock.patch('aiohttp.streams.internal_logger')
def test_read_eof_unread_data_no_warning(self, internal_logger):
# Read bytes.
stream = self._make_one()
stream.feed_eof()

self.loop.run_until_complete(stream.read())
self.loop.run_until_complete(stream.read())
self.loop.run_until_complete(stream.read())
self.loop.run_until_complete(stream.read())
self.loop.run_until_complete(stream.read())
stream.unread_data(b'data')
self.loop.run_until_complete(stream.read())
self.loop.run_until_complete(stream.read())
self.assertFalse(internal_logger.warning.called)

def test_read_until_eof(self):
# Read all bytes until eof.
stream = self._make_one()
Expand Down

0 comments on commit 5fce093

Please sign in to comment.