FactoryBoy: use a factory method on the model instead of __init__
I have a class, for which I would like to write a factory using FactoryBoy
. However, this class doesn’t produce its instances using the __init__
method, but rather a number of factory methods:
Factory-boy: use params in a factory.List field
I want to create a factory that will produce a list of dictionaries, and I want to be able to pass an iterable of items to serve as values for one of the items in those dicts, and I want the number of dicts in the list to be equal to the number of the items in the iterable I pass. Here’s what I wrote: