def test_write_bytes(): unpacker = Unpacker() unpacker.feed(b'abc') f = io.BytesIO() assert unpacker.unpack(f.write) == ord('a') assert f.getvalue() == b'a' f = io.BytesIO() assert unpacker.skip(f.write) is None assert f.getvalue() == b'b' f = io.BytesIO() assert unpacker.skip() is None assert f.getvalue() == b''
def test_foobar_skip(): unpacker = Unpacker(read_size=3, use_list=1) 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() with raises(OutOfData): unpacker.unpack()