conftest.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:do-portal 作者: certeu 项目源码 文件源码
def session(request, monkeypatch):
    """Prevent the session from closing"""
    # Roll back at the end of every test
    request.addfinalizer(_db.session.remove)

    # Prevent the session from closing (make it a no-op) and
    # committing (redirect to flush() instead)
    # https://alextechrants.blogspot.com/2014/01/unit-testing-sqlalchemy-apps-part-2.html
    # monkeypatch.setattr(_db.session, 'commit', _db.session.flush)
    monkeypatch.setattr(_db.session, 'remove', lambda: None)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号