28 septembre 2010

Using multiple inheritance for Python mocks

Today, I needed to mock just one function from a class instance.

I used multiple inheritance to achieve that like so:



The ProdEngineMock class inherits everything from the ProdEngine class, except the mocked function.

Nice and elegant!

Aucun commentaire:

Enregistrer un commentaire