I have my nice base test class which extends from the django test case and another class:
class MyTestCase(TestCase, TestFreshProvisionedEachTest):
Now it all works nicely, except that to make it work we have to patch (with Foord's mock library) a couple of functions in the middleware.
My idea is that this would have worked fine:
@patch('spotlight.middleware.extract_host_name', new=lambda host_name:
TEST_DOMAIN)
@patch('spotlight.middleware.extract_host_key', new=lambda host_key:
company_name_to_db(TEST_DOMAIN))
class MyTestCase(TestCase, TestFreshProvisionedEachTest):
However it doesn't seem to work, the methods of the subclass are not patched. I thought then that there could be a way to do something like
MyTestCase = patch(MyTestCase, 'spotlight.middleware.extract_host_name', new=lambda host_name: TEST_DOMAIN)
But that also is not possible.
Is there a way to avoid this repetition and do a patch on a superclass which patches all the subclasses methods as well?