This will break things that rely on nested sessions, such as the example above which use nested transaction to encapsulate tests. It seems like a good argument not to use nested transactions that way, but I think you should also try to avoid interfering with user transactions if possible.
Ie. I think you should either drop the session.commit() line, and let users interact with sessions how they want, or call session.begin_nested() before session.add, so that the commit will not effect parent transactions.
See https://docs.sqlalchemy.org/en/13/orm/session_transaction.html http://alextechrants.blogspot.com/2013/08/unit-testing-sqlalchemy-apps.html
L312 of https://github.com/klen/mixer/blob/develop/mixer/backend/sqlalchemy.py will end the session's current transaction and commit them.
This will break things that rely on nested sessions, such as the example above which use nested transaction to encapsulate tests. It seems like a good argument not to use nested transactions that way, but I think you should also try to avoid interfering with user transactions if possible.
Ie. I think you should either drop the session.commit() line, and let users interact with sessions how they want, or call session.begin_nested() before session.add, so that the commit will not effect parent transactions.