Made TestNoInitialDataLoading pass with MySQL (Refs #15926)
This commit is contained in:
parent
7edf231d46
commit
f0664dc8ae
|
@ -81,9 +81,8 @@ The full error: %s""" % (connection.settings_dict['NAME'], e))
|
||||||
# Reinstall the initial_data fixture.
|
# Reinstall the initial_data fixture.
|
||||||
kwargs = options.copy()
|
kwargs = options.copy()
|
||||||
kwargs['database'] = db
|
kwargs['database'] = db
|
||||||
if options.get('load_initial_data', True):
|
if options.get('load_initial_data'):
|
||||||
# Reinstall the initial_data fixture.
|
# Reinstall the initial_data fixture.
|
||||||
from django.core.management import call_command
|
|
||||||
call_command('loaddata', 'initial_data', **options)
|
call_command('loaddata', 'initial_data', **options)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -2,6 +2,7 @@ from optparse import make_option
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
from django.core.management import call_command
|
||||||
from django.core.management.base import NoArgsCommand
|
from django.core.management.base import NoArgsCommand
|
||||||
from django.core.management.color import no_style
|
from django.core.management.color import no_style
|
||||||
from django.core.management.sql import custom_sql_for_model, emit_post_sync_signal
|
from django.core.management.sql import custom_sql_for_model, emit_post_sync_signal
|
||||||
|
@ -27,7 +28,7 @@ class Command(NoArgsCommand):
|
||||||
verbosity = int(options.get('verbosity'))
|
verbosity = int(options.get('verbosity'))
|
||||||
interactive = options.get('interactive')
|
interactive = options.get('interactive')
|
||||||
show_traceback = options.get('traceback')
|
show_traceback = options.get('traceback')
|
||||||
load_initial_data = options.get('load_initial_data', True)
|
load_initial_data = options.get('load_initial_data')
|
||||||
|
|
||||||
self.style = no_style()
|
self.style = no_style()
|
||||||
|
|
||||||
|
@ -158,6 +159,5 @@ class Command(NoArgsCommand):
|
||||||
|
|
||||||
# Load initial_data fixtures (unless that has been disabled)
|
# Load initial_data fixtures (unless that has been disabled)
|
||||||
if load_initial_data:
|
if load_initial_data:
|
||||||
from django.core.management import call_command
|
|
||||||
call_command('loaddata', 'initial_data', verbosity=verbosity,
|
call_command('loaddata', 'initial_data', verbosity=verbosity,
|
||||||
database=db, skip_validation=True)
|
database=db, skip_validation=True)
|
||||||
|
|
|
@ -27,34 +27,12 @@ class TestNoInitialDataLoading(TestCase):
|
||||||
management.call_command(
|
management.call_command(
|
||||||
'syncdb',
|
'syncdb',
|
||||||
verbosity=0,
|
verbosity=0,
|
||||||
commit=False
|
|
||||||
)
|
|
||||||
self.assertQuerysetEqual(
|
|
||||||
Book.objects.all(), [
|
|
||||||
u'Achieving self-awareness of Python programs'
|
|
||||||
],
|
|
||||||
lambda a: a.name
|
|
||||||
)
|
|
||||||
|
|
||||||
Book.objects.all().delete()
|
|
||||||
|
|
||||||
management.call_command(
|
|
||||||
'syncdb',
|
|
||||||
verbosity=0,
|
|
||||||
commit=False,
|
|
||||||
load_initial_data=False
|
load_initial_data=False
|
||||||
)
|
)
|
||||||
self.assertQuerysetEqual(Book.objects.all(), [])
|
self.assertQuerysetEqual(Book.objects.all(), [])
|
||||||
|
|
||||||
def test_flush(self):
|
def test_flush(self):
|
||||||
Book.objects.all().delete()
|
# Test presence of fixture (flush called by TransactionTestCase)
|
||||||
|
|
||||||
management.call_command(
|
|
||||||
'flush',
|
|
||||||
verbosity=0,
|
|
||||||
interactive=False,
|
|
||||||
commit=False
|
|
||||||
)
|
|
||||||
self.assertQuerysetEqual(
|
self.assertQuerysetEqual(
|
||||||
Book.objects.all(), [
|
Book.objects.all(), [
|
||||||
u'Achieving self-awareness of Python programs'
|
u'Achieving self-awareness of Python programs'
|
||||||
|
@ -62,12 +40,9 @@ class TestNoInitialDataLoading(TestCase):
|
||||||
lambda a: a.name
|
lambda a: a.name
|
||||||
)
|
)
|
||||||
|
|
||||||
Book.objects.all().delete()
|
|
||||||
|
|
||||||
management.call_command(
|
management.call_command(
|
||||||
'flush',
|
'flush',
|
||||||
verbosity=0,
|
verbosity=0,
|
||||||
commit=False,
|
|
||||||
interactive=False,
|
interactive=False,
|
||||||
load_initial_data=False
|
load_initial_data=False
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue