Python factory 模块,SubFactory() 实例源码

我们从Python开源项目中,提取了以下2个代码示例,用于说明如何使用factory.SubFactory()

项目:a4-meinberlin    作者:liqd    | 项目源码 | 文件源码
def projects(self, create, extracted, **kwargs):
        if not extracted:
            project_factory = factory.SubFactory(ProjectFactory).get_factory()
            self.projects.add(project_factory())

        elif extracted:
            for project in extracted:
                self.projects.add(project)
项目:adhocracy4    作者:liqd    | 项目源码 | 文件源码
def moderators(self, create, extracted, **kwargs):
        if not extracted:
            user_factory = factory.SubFactory(USER_FACTORY).get_factory()
            self.moderators.add(user_factory())
            return

        if extracted:
            for user in extracted:
                self.moderators.add(user)