Add test for .skip()

This commit is contained in:
INADA Naoki 2012-09-23 10:09:51 +09:00
parent 9963522d46
commit 48d693c1b9
2 changed files with 15 additions and 1 deletions

View file

@ -451,7 +451,7 @@ cdef class Unpacker(object):
else:
self.file_like = None
cdef _unpack(self, bint construct):
cdef object _unpack(self, bint construct):
cdef int ret
cdef object obj
while 1:

View file

@ -28,6 +28,20 @@ def test_foobar():
k += 1
assert k == len(b'foobar')
def test_foobar_skip():
unpacker = Unpacker(read_size=3)
unpacker.feed(b'foobar')
assert unpacker.unpack() == ord(b'f')
unpacker.skip()
assert unpacker.unpack() == ord(b'o')
unpacker.skip()
assert unpacker.unpack() == ord(b'a')
unpacker.skip()
try:
o = unpacker.unpack()
assert 0, "should raise exception"
except StopIteration:
assert 1, "ok"
def test_maxbuffersize():
nose.tools.assert_raises(ValueError, Unpacker, read_size=5, max_buffer_size=3)