FactoryBoy / factory_boy

A test fixtures replacement for Python
https://factoryboy.readthedocs.io/
MIT License
3.49k stars 392 forks source link

How does factory boy know of what type a field is? #834

Closed mdczaplicki closed 3 years ago

mdczaplicki commented 3 years ago

I'm trying to make a tweak to factory boy so that it resolves properly pydantic models, but I'm not able to find a code responsible for getting the types for Django or SQLAlchemy models & generating proper values for these parameters.
Where is the code that's responsible for this?

rbarrois commented 3 years ago

There isn't. Factory_boy will provide the values you've taught it to use :) If a field should be an integer, provide an integer to the definition.

However, there is a planned (but not ready) feature to have factory_boy analyse a model class and generate declarations for it; at that stage, there will be a documentation for this mechanism and for hooks useful to make it compatible with various model frameworks.