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()