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)
)
评论列表
文章目录