Skip to content

Commit 487460d

Browse files
adamchainztimgraham
authored andcommitted
Fix for Django 1.10 loaddata
loaddata raises a CommandError instead of showing a warning when the specified fixture file is not found.
1 parent d6bb6c6 commit 487460d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

djangobench/utils.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,19 @@ def run_benchmark(benchmark, migrate=True, setup=None, trials=None, handle_argv=
5757
if hasattr(django, 'setup'):
5858
django.setup()
5959
if migrate:
60-
from django.core.management import call_command
60+
from django.core.management import CommandError, call_command
6161
if django.VERSION < (1, 7):
6262
call_command("syncdb", run_syncdb=True, verbosity=0)
6363
else:
6464
call_command("migrate", run_syncdb=True, verbosity=0)
6565
if django.VERSION >= (1, 8):
66-
call_command("loaddata", "initial_data", verbosity=0)
66+
try:
67+
call_command("loaddata", "initial_data", verbosity=0)
68+
except CommandError as exc:
69+
# Django 1.10+ raises if the file doesn't exist and not
70+
# all benchmarks have files.
71+
if 'No fixture named' not in str(exc):
72+
raise
6773

6874
if setup:
6975
setup()

0 commit comments

Comments
 (0)