Beispiel #1
0
    def test_manualreset(self, sizes=[0, 5, 50, 1000]):
        packer = Packer(autoreset=False)
        for size in sizes:
            packer.pack_array_header(size)
            for i in range(size):
                packer.pack(i)

        bio = BytesIO(packer.bytes())
        unpacker = Unpacker(bio, use_list=1)
        for size in sizes:
            assert unpacker.unpack() == list(range(size))

        packer.reset()
        assert packer.bytes() == b''
Beispiel #2
0
    def test_manualreset(self, sizes=[0, 5, 50, 1000]):
        packer = Packer(autoreset=False)
        for size in sizes:
            packer.pack_array_header(size)
            for i in range(size):
                packer.pack(i)

        bio = compat.BytesIO(packer.bytes())
        unpacker = Unpacker(bio, use_list=1)
        for size in sizes:
            assert unpacker.unpack() == list(range(size))

        packer.reset()
        assert packer.bytes() == b''
Beispiel #3
0
    def testArraySize(self, sizes=[0, 5, 50, 1000]):
        bio = BytesIO()
        packer = Packer()
        for size in sizes:
            bio.write(packer.pack_array_header(size))
            for i in range(size):
                bio.write(packer.pack(i))

        bio.seek(0)
        unpacker = Unpacker(bio, use_list=1)
        for size in sizes:
            assert unpacker.unpack() == list(range(size))
Beispiel #4
0
    def testArraySize(self, sizes=[0, 5, 50, 1000]):
        bio = compat.BytesIO()
        packer = Packer()
        for size in sizes:
            bio.write(packer.pack_array_header(size))
            for i in range(size):
                bio.write(packer.pack(i))

        bio.seek(0)
        unpacker = Unpacker(bio, use_list=1)
        for size in sizes:
            assert unpacker.unpack() == list(range(size))
Beispiel #5
0
 def test_array_header(self):
     packer = Packer()
     packer.pack_array_header(2 ** 32 - 1)
     pytest.raises((OverflowError, ValueError),
                   packer.pack_array_header, 2 ** 32)
 def test_map_header(self):
     packer = Packer()
     packer.pack_map_header(2**32 - 1)
     with pytest.raises((OverflowError, ValueError)):
         packer.pack_array_header(2**32)
Beispiel #7
0
 def test_map_header(self):
     packer = Packer()
     packer.pack_map_header(2 ** 32 - 1)
     with pytest.raises((OverflowError, ValueError)):
         packer.pack_array_header(2 ** 32)