From c1eeb5671e3875e4ee192aab40d6bd8144d453bf Mon Sep 17 00:00:00 2001 From: Fabio Caccamo Date: Thu, 20 Feb 2020 17:15:53 +0100 Subject: [PATCH] Added pickle encode/decode tests. --- tests/serializers/test_pickle_serializer.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/tests/serializers/test_pickle_serializer.py b/tests/serializers/test_pickle_serializer.py index 0b94b19..15de9d1 100644 --- a/tests/serializers/test_pickle_serializer.py +++ b/tests/serializers/test_pickle_serializer.py @@ -1,16 +1,26 @@ # -*- coding: utf-8 -*- +from benedict.serializers import Base64Serializer from benedict.serializers import PickleSerializer +import datetime as dt import unittest class pickle_serializer_test_case(unittest.TestCase): def test_decode_pickle(self): - # TODO - pass + s = 'gAN9cQBYBAAAAGRhdGVxAWNkYXRldGltZQpkYXRldGltZQpxAkMKB8EEAwAAAAAAAHEDhXEEUnEFcy4=' + d = Base64Serializer().decode(s, subformat='pickle') + r = { + 'date': dt.datetime(year=1985, month=4, day=3), + } + self.assertEqual(d, r) def test_encode_pickle(self): - # TODO - pass + d = { + 'date': dt.datetime(year=1985, month=4, day=3), + } + s = Base64Serializer().encode(d, subformat='pickle') + r = 'gAN9cQBYBAAAAGRhdGVxAWNkYXRldGltZQpkYXRldGltZQpxAkMKB8EEAwAAAAAAAHEDhXEEUnEFcy4=' + self.assertEqual(s, r)