Isolating py.test DB sessions in Flask-SQLAlchemy
问题 I'm trying to build a Flask app with Flask-SQLAlchemy; I use pytest to test the DB. One of the problems seems to be creating isolated DB sessions between different tests. I cooked up a minimal, complete example to highlight the problem, note that test_user_schema1() and test_user_schema2() are the same. Filename: test_db.py from models import User def test_user_schema1(session): person_name = 'Fran Clan' uu = User(name=person_name) session.add(uu) session.commit() assert uu.id==1 assert uu