Skip to content

Commit

Permalink
Add explicitly-named test for 'BufferedStream._bytes_remaining'.
Browse files Browse the repository at this point in the history
Addresses:
#1192 (comment)
  • Loading branch information
tseaver committed Oct 26, 2015
1 parent 56ce426 commit d7b4ffb
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion gcloud/_apitools/test_buffered_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ def test_ctor_start_zero_longer_than_buffer(self):
self.assertEqual(len(bufstream), BUFSIZE)
self.assertFalse(bufstream.stream_exhausted)
self.assertEqual(bufstream.stream_end_position, BUFSIZE)
self.assertEqual(bufstream._bytes_remaining, BUFSIZE)

def test_ctor_start_nonzero_shorter_than_buffer(self):
from io import BytesIO
Expand All @@ -42,6 +41,24 @@ def test_ctor_start_nonzero_shorter_than_buffer(self):
self.assertEqual(len(bufstream), len(CONTENT) - START)
self.assertTrue(bufstream.stream_exhausted)
self.assertEqual(bufstream.stream_end_position, len(CONTENT))

def test__bytes_remaining_start_zero_longer_than_buffer(self):
from io import BytesIO
CONTENT = b'CONTENT GOES HERE'
START = 0
BUFSIZE = 4
stream = BytesIO(CONTENT)
bufstream = self._makeOne(stream, START, BUFSIZE)
self.assertEqual(bufstream._bytes_remaining, BUFSIZE)

def test__bytes_remaining_start_zero_shorter_than_buffer(self):
from io import BytesIO
CONTENT = b'CONTENT GOES HERE'
START = 8
BUFSIZE = 10
stream = BytesIO(CONTENT)
stream.read(START) # already consumed
bufstream = self._makeOne(stream, START, BUFSIZE)
self.assertEqual(bufstream._bytes_remaining, len(CONTENT) - START)

def test_read_w_none(self):
Expand Down

0 comments on commit d7b4ffb

Please sign in to comment.