def test_map_stream(self):
     packed_value = b"\xDB\x81A\x01\x81B\x02\xDF"
     unpacked_value = {u"A": 1, u"B": 2}
     stream_out = BytesIO()
     packer = Packer(stream_out)
     packer.pack_map_stream_header()
     packer.pack(u"A")
     packer.pack(1)
     packer.pack(u"B")
     packer.pack(2)
     packer.pack_end_of_stream()
     packed = stream_out.getvalue()
     try:
         assert packed == packed_value
     except AssertionError:
         raise AssertionError("Packed value is %r instead of expected %r" %
                              (packed, packed_value))
     stream_in = BytesIO(packed)
     unpacker = Unpacker(stream_in)
     unpacked = next(unpacker.unpack())
     try:
         assert unpacked == unpacked_value
     except AssertionError:
         raise AssertionError(
             "Unpacked value %r is not equal to expected %r" %
             (unpacked, unpacked_value))
 def test_map_stream(self):
     packed_value = b"\xDB\x81A\x01\x81B\x02\xDF"
     unpacked_value = {u"A": 1, u"B": 2}
     stream_out = BytesIO()
     packer = Packer(stream_out)
     packer.pack_map_stream_header()
     packer.pack(u"A")
     packer.pack(1)
     packer.pack(u"B")
     packer.pack(2)
     packer.pack_end_of_stream()
     packed = stream_out.getvalue()
     try:
         assert packed == packed_value
     except AssertionError:
         raise AssertionError("Packed value is %r instead of expected %r" %
                              (packed, packed_value))
     stream_in = BytesIO(packed)
     unpacker = Unpacker(stream_in)
     unpacked = next(unpacker.unpack())
     try:
         assert unpacked == unpacked_value
     except AssertionError:
         raise AssertionError("Unpacked value %r is not equal to expected %r" %
                              (unpacked, unpacked_value))