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
?
create()
is for mocking a single instance of a class.create_batch(size, ...)
is for mocking multiple instances.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).