Skip to content

Instantly share code, notes, and snippets.

@sfsekaran
Last active Apr 28, 2021
Embed
What would you like to do?
Per-Test Database Cleaner (Flask-SQLAlchemy + PyTest)
@pytest.fixture(autouse=True)
def database_cleaner():
db.session.begin()
yield
db.session.rollback()
@rs-sathya
Copy link

Note to self: may have to use session.begin_nested() instead of begin()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment