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)
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)
def dump(obj, fname): return serializer.dump(obj, fname)
def dump(obj, fname, protocol=2): l = serializer.dump(obj, fname, protocol) return l