jeancochrane / jeancochrane/pytest-flask-sqlalchemy
Disable session.remove on flask_sqlalchemy.SQLAlchemy
Open
- Dominant language
- Python
- Stars
- 253
- Forks
- 45
- PR merge metrics
- No merged PRs in 30d
Description
With Flask-SQLAlchemy 2.4.0, SQLAlchemy 1.3.3 and pytest-flask-sqlalchemy 1.0.2, I sometimes (non-deterministically) got `DetachedInstanceError` because the session instantiated in the `flask_sqlalchemy.SQLAlchemy` extension already terminated the session (https://github.com/pallets/flask-sqlalchemy/blob/master/flask_sqlalchemy/__init__.py#L849).
Adding something like this to `conftest.py` helped.
```
mocker.patch.object(sqla.session, "remove", lambda: None)
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.