def _read_until(self, until, keep, expected): b = ByteStream('adam michael vandenberg') words = list() while not b.eof(): words.append(b.read_until(until, keep=keep)) self.assertEquals(expected, words) self.assert_(b.eof())
def test_word(self): "Reading words should behave as expected." b = ByteStream(self.sample_bytes) words = list() for i in range(len(self.sample_bytes)/2): words.append(b.word()) self.assertEquals([2*256+1, 4*256+3, 6*256+5], words) self.assert_(b.eof())
def test_byte(self): "Reading bytes should behave as expected." b = ByteStream(self.sample_bytes) bytes = list() for i in range(len(self.sample_bytes)): bytes.append(b.byte()) self.assertEquals([1,2,3,4,5,6], bytes) self.assert_(b.eof())