I used multiple inheritance to achieve that like so:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ProductDefinitionMock(object): | |
def function_to_mock(self, product_dict): | |
return None | |
class ProdEngineMock(ProductDefinitionMock, ProdEngine): | |
pass | |
class MyTests(TestCase): | |
def setUp(self): | |
self.prod_engine = ProdEngineMock(...) |
The ProdEngineMock class inherits everything from the ProdEngine class, except the mocked function.
Nice and elegant!
Aucun commentaire:
Enregistrer un commentaire