-
Notifications
You must be signed in to change notification settings - Fork 42
No parameters generated for model-only attributres #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Note that this is because |
That's right. I actually started working on a project called alchemyboy time ago. The idea is to generate factories based on the model. |
I agree that FactoryBoy needs something similar to |
You can try fixing it for your project for now. So basically you need a metaclass and a base class for model factories that will generate base attributes with incorporating default column values into LazyAttribute. |
I don't know SQLAlchemy + FactoryBoy now since we use Django models, but FactoryBoy already accepts the model parameters even if they're not specified on the factory. It's just that pytest-factoryboy doesn't know that and doesn't convert them into fixture parameters. |
I created an issue to extend FactoryBoy. |
Do you mean if you have a shallow factory like one above and then if you pass any of the arguments during creation of an object like BookFactory(title="bla") it works? |
Yes, |
That certainly sounds interesting. An |
FactoryBoy/factory_boy@6f20207 and the commits around it might be relevant? |
Due to these limitations I ended up not using this project and currently I don't work on any Django projects so my need for this no longer exists. Feel free to close this. |
Uh oh!
There was an error while loading. Please reload this page.
No parameters are generated for model-only parameters. We often have Django model defaults which we don't override in factories, but do override in tests. For example:
This results in
ValueError: <function test_title at 0x7efe970a2488> uses no fixture 'book__title'
If I add the title to the BookFactory it does work.
Result of pip freeze:
The text was updated successfully, but these errors were encountered: