jeancochrane / pytest-flask-sqlalchemy

A pytest plugin for preserving test isolation in Flask-SQLAlchemy using database transactions.
MIT License
255 stars 45 forks source link

Fix flask-sqlalchemy regression #64

Closed dwreeves closed 1 year ago

dwreeves commented 1 year ago

In the latest version of Flask-SQLAlchemy, the method SQLAlchemy.create_scoped_session was renamed to SQLAlchemy._make_scoped_session, which causes a regression. I've added handling for this regression. I've also updated the workflows to test against Flask-SQLAlchemy 2 and 3.

I confirmed that this fix works by making the modification in a venv/ in which I am using pytest-flask-sqlalchemy and then running my tests with the changes.

dwreeves commented 1 year ago

Oh no... so apparently I was calling _db with a live application context in my test suite, which is why I didn't identify another regression, which is that SQLAlchemy 3.0 requires the app context to work. I'm closing for now. Fixing this would likely require some sort of breaking change to pytest-flask-sqlalchemy.