Last active
April 28, 2021 07:50
-
-
Save sfsekaran/cf232f76fc2c2f682ca45551329b9e77 to your computer and use it in GitHub Desktop.
Per-Test Database Cleaner (Flask-SQLAlchemy + PyTest)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@pytest.fixture(autouse=True) | |
def database_cleaner(): | |
db.session.begin() | |
yield | |
db.session.rollback() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note to self: may have to use
session.begin_nested()
instead ofbegin()