サブクラスから親ファクトリのメソッドを呼び出す方法はありますか?
はクラスのインスタンスではなく、ファクトリが返すオブジェクトであるため、通常のsuper(ThisClass, self)
orParentClass.method(self)
メソッドは機能しません。self
class SomethingFactory(factory.DjangoModelFactory):
# Meta, fields, etc
@factory.post_generation
def post(self, create, extracted, **kwargs):
# Some steps
class SomethingElseFactory(SomethingFactory):
@factory.post_generation
def post(self, create, extracted, **kwargs):
super(SomethingElseFactory, self).post(create, extracted, **kwargs)
エラーはTypeError: super(type, obj): obj must be an instance or subtype of type
です。
(ショートカットsuper().post(create, extracted, kwargs)
は同じエラーを生成します。)
SomethingFactory.post
サブクラスからその親ファクトリ メソッドにアクセスするにはどうすればよいですか?