Exemplo n.º 1
0
 def test_load_from_and_dump_to_file(self):
     stream = io.BytesIO()
     data = [123, {}, 124]
     pickle.dump(data, stream)
     stream.seek(0)
     unpickled = pickle.load(stream)
     self.assertEqual(unpickled, data)
Exemplo n.º 2
0
 def test_callapi(self):
     f = io.BytesIO()
     # With and without keyword arguments
     pickle.dump(123, f, -1)
     pickle.dump(123, file=f, protocol=-1)
     pickle.dumps(123, -1)
     pickle.dumps(123, protocol=-1)
     pickle.Pickler(f, -1)
     pickle.Pickler(f, protocol=-1)
Exemplo n.º 3
0
 def dump(obj, fname):
     return serializer.dump(obj, fname)
Exemplo n.º 4
0
def dump(obj, fname, protocol=2):
    l = serializer.dump(obj, fname, protocol)
    return l