Made TestNoInitialDataLoading pass with MySQL (Refs #15926)

This commit is contained in:
Claude Paroz 2012-06-06 13:53:12 +02:00
parent 7edf231d46
commit f0664dc8ae
3 changed files with 5 additions and 31 deletions

View File

@ -81,9 +81,8 @@ The full error: %s""" % (connection.settings_dict['NAME'], e))
# Reinstall the initial_data fixture.
kwargs = options.copy()
kwargs['database'] = db
if options.get('load_initial_data', True):
# Reinstall the initial_data fixture.
from django.core.management import call_command
if options.get('load_initial_data'):
# Reinstall the initial_data fixture.
call_command('loaddata', 'initial_data', **options)
else:

View File

@ -2,6 +2,7 @@ from optparse import make_option
import traceback
from django.conf import settings
from django.core.management import call_command
from django.core.management.base import NoArgsCommand
from django.core.management.color import no_style
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'))
interactive = options.get('interactive')
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()
@ -158,6 +159,5 @@ class Command(NoArgsCommand):
# 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, skip_validation=True)

View File

@ -27,34 +27,12 @@ class TestNoInitialDataLoading(TestCase):
management.call_command(
'syncdb',
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
)
self.assertQuerysetEqual(Book.objects.all(), [])
def test_flush(self):
Book.objects.all().delete()
management.call_command(
'flush',
verbosity=0,
interactive=False,
commit=False
)
# Test presence of fixture (flush called by TransactionTestCase)
self.assertQuerysetEqual(
Book.objects.all(), [
u'Achieving self-awareness of Python programs'
@ -62,12 +40,9 @@ class TestNoInitialDataLoading(TestCase):
lambda a: a.name
)
Book.objects.all().delete()
management.call_command(
'flush',
verbosity=0,
commit=False,
interactive=False,
load_initial_data=False
)