FactoryBoy / factory_boy

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

How can you globally set sqlalchemy session persistence? #450

Open mark0978 opened 6 years ago

mark0978 commented 6 years ago

Not quite seeing how to do this without updating the base class of all of my factories. Surely there is an easier way to do this.

https://stackoverflow.com/questions/48568472/how-can-you-globally-set-sqlalchemy-session-persistence-for-factory-boy-in-only

rbarrois commented 6 years ago

Hi!

As a global design choice, we try to avoid any global state for the library — some of the factories could be used as a testing tool for a shared piece of code, and we wouldn't want to impose a specific way of setting up the testing environment to all those projects.

However, there might be some features (either in the SQLAlchemyModelFactory or in SQLAlchemy itself) to handle your case; I think @jeffwidman could help on this — he's the project's SQLAlchemy expert :)