util.py 文件源码

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

项目:micromasters 作者: mitodl 项目源码 文件源码
def should_load_from_existing_db(database_loader, cursor):
    """
    Helper method to determine whether or not a backup database should be loaded to begin
    test execution. A backup db should be used if that backup exists, and if the pytest config
    options don't indicate that the database should be freshly created to start the the test
    suite execution.

    Args:
        database_loader (DatabaseLoader): A DatabaseLoader instance
        cursor (django.db.connection.cursor): A database cursor

    Returns:
        bool: Whether or not a backup database should be loaded to begin test execution
    """
    # We should load a db backup to start the test suite if that backup exists,
    # and if the config options don't indicate that the database should be freshly
    # created to start the the test suite execution
    return (
        pytest.config.option.reuse_db and
        not pytest.config.option.create_db and
        database_loader.has_backup(db_cursor=cursor)
    )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号