These are chat archives for pythonvietnam/Flask

Jul 2017
Jacek BroĊ„ski-Jankowski
Jul 12 2017 12:57

Hi, anyone succeeded on running Alembic upgrade() in pytest fixture with SQLite in-memory DB?

def app():
    """An application for the tests."""
    _app = create_app(TestConfig)
    ctx = _app.test_request_context()

    yield _app


def db(request, app): = app
    with app.app_context():
        from flask_migrate import upgrade

    yield _db

    # Explicitly close DB connection

I checked with pdb that alembic script is being executed but those changes are not reflected in tests. Using _db.create_all() works but I need to perform migrations in tests as they contain data upgrades. Help appreciated!

I'd prefer a cleaner solution than proposed here: