mardi 2 octobre 2018

Good way to define db fixture

I'm making a fixture for db using pytest as below:

@pytest.fixture(scope='function')
def db(app, request):
    with app.app_context():
        _db.create_all()
        yield _db
        _db.drop_all()

However, for each test takes too long. db.create_all and db.drop_all are too slow. How can I improve the speed?

I'm using postgresql 10, flask-sqlalchemy and pytest

Aucun commentaire:

Enregistrer un commentaire