mirror of
https://github.com/django/django.git
synced 2025-11-07 07:15:35 +00:00
Refs #14661 -- Clarified the handling of initial data injected via custom SQL.
This is BACKWARDS INCOMPATIBLE CHANGE for anyone relying on SQL-injected initial data in a test case. git-svn-id: http://code.djangoproject.com/svn/django/trunk@15239 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -26,6 +26,10 @@ class Command(NoArgsCommand):
|
||||
interactive = options.get('interactive')
|
||||
show_traceback = options.get('traceback', False)
|
||||
|
||||
# Stealth option -- 'load_initial_data' is used by the testing setup
|
||||
# process to disable initial fixture loading.
|
||||
load_initial_data = options.get('load_initial_data', True)
|
||||
|
||||
self.style = no_style()
|
||||
|
||||
# Import the 'management' module within each installed app, to register
|
||||
@@ -154,5 +158,7 @@ class Command(NoArgsCommand):
|
||||
else:
|
||||
transaction.commit_unless_managed(using=db)
|
||||
|
||||
from django.core.management import call_command
|
||||
call_command('loaddata', 'initial_data', verbosity=verbosity, database=db)
|
||||
# Load initial_data fixtures (unless that has been disabled)
|
||||
if load_initial_data:
|
||||
from django.core.management import call_command
|
||||
call_command('loaddata', 'initial_data', verbosity=verbosity, database=db)
|
||||
|
||||
@@ -359,7 +359,21 @@ class BaseDatabaseCreation(object):
|
||||
# Report syncdb messages at one level lower than that requested.
|
||||
# This ensures we don't get flooded with messages during testing
|
||||
# (unless you really ask to be flooded)
|
||||
call_command('syncdb', verbosity=max(verbosity - 1, 0), interactive=False, database=self.connection.alias)
|
||||
call_command('syncdb',
|
||||
verbosity=max(verbosity - 1, 0),
|
||||
interactive=False,
|
||||
database=self.connection.alias,
|
||||
load_initial_data=False)
|
||||
|
||||
# We need to then do a flush to ensure that any data installed by
|
||||
# custom SQL has been removed. The only test data should come from
|
||||
# test fixtures, or autogenerated from post_syncdb triggers.
|
||||
# This has the side effect of loading initial data (which was
|
||||
# intentionally skipped in the syncdb).
|
||||
call_command('flush',
|
||||
verbosity=max(verbosity - 1, 0),
|
||||
interactive=False,
|
||||
database=self.connection.alias)
|
||||
|
||||
from django.core.cache import get_cache
|
||||
from django.core.cache.backends.db import BaseDatabaseCache
|
||||
|
||||
Reference in New Issue
Block a user