Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Django ImageField is a SubFactory now, should it be? #451
I've received an issue pytest-dev/pytest-factoryboy#58
pytest-factoryboy introspects the declarations in order to create fixtures automatically related to the current factory.
So far I'm comparing isinstance(decl, SubFactory) and isinstance(decl, RelatedFactory).
I could check exact types like if type(decl, SubFactory) then create fixture for the model referenced by SubFactory. But this will prevent from subclassing a SubFactory in the valid cases.
@marky1991 I introspect the attributes in order to generate fixtures. SubFactory means that there's a factory behind it. I think Dict is a factory that has a dict as a model. Dict isn't really a subfactory that has a factory of yet another factory that is just an indirection to come to the dict or an orderdereddict.
dict_factory as a parameter makes very little sense to me, model as a parameter would do more sense. Which dict you want to use. Honestly ordereddict doesn't make a lot of sense to me, because once you iterate over it's items it is no longer a dict. Dict is an interface with an index operator .
Dict(ordered=True) or Dict(model_class=ordereddict) would make more sense than being a SubFactory.
The question is how far did it go and can it be undone?
referenced this issue
Feb 11, 2018
@olegpidsadnyi Indeed, the design wasn't very clean - mostly a shortcut to keep these fields working after the core refactory.
I've changed it to a cleaner and more explicit design, which should help with your issue.
On the other hand, I make no guarantee on the class names or hierarchy, beyond the