def test_bytes_preservation(self): """ Tests that bytestrings and unicode strings' types are preserved. """ data = { b'bytes_key': b'this is a byte array', 'unicode_key': 'unicode string!', } serializer = MsgpackSerializer() output = serializer.blob_to_dict(serializer.dict_to_blob(data)) assert b'bytes_key' in output assert 'unicode_key' in output assert output[b'bytes_key'] == b'this is a byte array' assert output['unicode_key'] == 'unicode string!'
def test_currint(self, value): serializer = MsgpackSerializer() assert serializer.blob_to_dict(serializer.dict_to_blob({'v': value}))['v'] == value
def test_datetime_utc(self, value): serializer = MsgpackSerializer() deserialized = serializer.blob_to_dict(serializer.dict_to_blob({'v': value}))['v'] # type: datetime.datetime assert deserialized == value assert deserialized.tzinfo == pytz.UTC