def django_db_setup(django_db_setup, django_db_blocker, database_loader):
"""
Fixture provided by pytest-django to allow for custom Django database config.
'django_db_setup' exists in the arguments because we want to perform the normal pytest-django
database setup before applying our own changes.
"""
with django_db_blocker.unblock():
with connection.cursor() as cur:
load_from_existing_db = should_load_from_existing_db(database_loader, cur)
if not load_from_existing_db:
# Drop a wagtail table due to a bug: https://github.com/wagtail/wagtail/issues/1824
cur.execute('DROP TABLE IF EXISTS wagtailsearch_editorspick CASCADE;')
# Create the initial post-migration database backup to be restored before each test case
database_loader.create_backup(db_cursor=cur)
if load_from_existing_db:
with django_db_blocker.unblock():
terminate_db_connections()
database_loader.load_backup()
评论列表
文章目录