Search code examples
djangodjango-testingdjango-testsfactory-boy

Django Factory Boy Create vs create_batch


I am learning django test and i found django factory boy library very helpfull for writing testcase but one thing i am not getting..

forexample my one of Factory name is BlogFactory

so i notice, most of the people use this like this: BlogFactory.create() and some people use it like this.. BlogFactory.create_batch() I am not getting difference between it..

What is different between create and create_batch ?


Solution

  • The create_batch method of a factory cannot be called without parameters as create(), since size is required by design (see the docs link above).