mardi 1 mars 2016

Create object that cannot be pickled

How can I easily create an object that cannot be pickled for testing edge cases in my rpc code?

It needs to be:

  1. Simple
  2. Reliable (not expected to break in future versions of python or pickle)
  3. Cross platform

Edit: The intended use looks something like this:

class TestRPCServer:
    def foo(self):
        return MagicalUnpicklableObject()

def test():
    with run_rpc_server_and_connect_to_it() as proxy:
        with nose.assert_raises(pickle.PickleError):
            proxy.foo()

Aucun commentaire:

Enregistrer un commentaire