Open adamchainz opened 2 years ago
Indeed, a workaround would be possible, the simplest one would be Meta.rename
:
class ContainerFactory:
class Meta:
model = Container
rename = {
"size_": "size"
}
And then calling ContainerFactory.create_batch(3, size_=5)
Nevertheless, I agree with the initial issue; it would however be somewhat complicated to change, as that pattern (create_batch(size=...
) is already used by lots of user code.
The problem
Take a model with a
size
attr:This is a somewhat reasonable/common name.
Unfortunately such a name precludes a factory for making such models in batch, with
create_batch()
/build_batch()
/generate_batch()
.With this factory:
One gets:
Proposed solution
Change the argument name to something obscure like
BATCH_SIZE
(mirroringFACTORY_CLASS
) or__factory_boy_size
.Extra notes
I think a workaround is possible with other hooks in factory boy?