I am trying to inherit from two ~Factory factory_boy classes, but it seems only the first class is inherited from, and the second is ignored. (They do have a common parent.)
class BasicFactory(factory.DjangoModelFactory):
# Meta class, some SubFactories and RelatedFactoriues, a post_generation method
class BasicFactoryWithExtraRelatedFactories(BasicFactory):
another_related = factory.RelatedFactory(SomethingElseFactory, 'basic', etc)
class BasicFactoryWithExtraPostGeneration(BasicFactory):
@factory.post_generation
def post(self, create, extracted, **kwargs):
"""
A replacement post_generation method
"""
class ExtraRelatedAndExtraPostGenerationFactory(BasicFactoryWithExtraRelatedFactories, BasicFactoryWithExtraPostGeneration)
"""
This seems to inherit the extra RelatedFactories, but not the extra post_generation method.
"""
class ExtraRelatedAndExtraPostGenerationFactory(BasicFactoryWithExtraPostGeneration, BasicFactoryWithExtraRelatedFactories)
"""
This seems to inherit the extra post_generation method, but not the extra RelatedFactories.
"""
Is there any way I can inherit both?
This is a tall order, I know, but it would enable such a fantastically beautiful solution to a problem I've got, whereby I could create all my required combinations of test cases simply with multiple inheritance. (I recognise that it is probably not 'simple' to support in factory_boy.)