kuzxnia / async_factory_boy

factory_boy extension with asynchronous ORM support
https://pypi.org/project/async-factory-boy/
MIT License
18 stars 7 forks source link

Support sqlalchemy session factory #6

Open a1d4r opened 9 months ago

a1d4r commented 9 months ago

There are cases where factory-boy is used not only in tests, but in scripts or even the application itself (for example, populating the real database with fake data). In such scenarios, the provided SQLAlchemy sessions have to be different. However, the current implementation forces users to hardcode the session in the Meta class. For flexibility, I suggest supporting another way to set the session (via callable), with analogy to the following PR: https://github.com/FactoryBoy/factory_boy/pull/927

kuzxnia commented 6 months ago

Thanks for offering a PR, with tests! 🎉

kuzxnia commented 6 months ago

to make this work we need to upgrade factory-boy version up to 3.3.0 - from that version, they added sqlalchemy_session_factory which is needed for this to work, adjust setup.cfg and I will add this feature to the next version

doiodl commented 4 months ago

Hello, when it will be on master?