1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Skip model validation when models are known good.

In some situations Django calls model validation when the models are
already known good. This is most visible in tests, which use flush
and loaddata commands. This resulted in around 10% overhead when
running tests under sqlite.
This commit is contained in:
Anssi Kääriäinen
2012-05-01 08:40:04 +03:00
parent 583f1d7425
commit 4fdd378beb
3 changed files with 11 additions and 8 deletions

View File

@@ -468,13 +468,14 @@ class TransactionTestCase(SimpleTestCase):
else:
databases = [DEFAULT_DB_ALIAS]
for db in databases:
call_command('flush', verbosity=0, interactive=False, database=db)
call_command('flush', verbosity=0, interactive=False, database=db,
skip_validation=True)
if hasattr(self, 'fixtures'):
# We have to use this slightly awkward syntax due to the fact
# that we're using *args and **kwargs together.
call_command('loaddata', *self.fixtures,
**{'verbosity': 0, 'database': db})
**{'verbosity': 0, 'database': db, 'skip_validation': True})
def _urlconf_setup(self):
if hasattr(self, 'urls'):
@@ -826,7 +827,8 @@ class TestCase(TransactionTestCase):
**{
'verbosity': 0,
'commit': False,
'database': db
'database': db,
'skip_validation': True,
})
def _fixture_teardown(self):