-
In the prior release, with SQLAlchemy 1.4 and Flask-SQLAlchemy 2.5.1, I had my conftest.py create a session for testing as follows:
This would allow my pytests to use Flask-SQLAlchemy models, commit them with the session, and know that the test database was in its original state at the end of the test. In the current 3.x release, this no longer works. I have verified that I can use SQLAlchemy directly to create a SQLAlchemy Session with sqlalchemy.orm.sessionmaker, passing it join_transaction_mode="create_savepoint". This causes begin_nested to be used, and the database is not modified at the end of my test. I have tried passing that join_transaction_mode to the _make_scoped_session private member function, but somehow that still writes things to the database during the test, and there is no way to roll it back. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
See #1171. Rather than trying to patch |
Beta Was this translation helpful? Give feedback.
See #1171. Rather than trying to patch
session
or use private methods, patch the contents ofdb.engines
.