From 487460d9cdcfa9b899314c963337f68e5323605d Mon Sep 17 00:00:00 2001 From: Adam Chainz Date: Wed, 23 Nov 2016 12:11:10 +0000 Subject: [PATCH] Fix for Django 1.10 loaddata loaddata raises a CommandError instead of showing a warning when the specified fixture file is not found. --- djangobench/utils.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/djangobench/utils.py b/djangobench/utils.py index ec3dc94..23414ed 100644 --- a/djangobench/utils.py +++ b/djangobench/utils.py @@ -57,13 +57,19 @@ def run_benchmark(benchmark, migrate=True, setup=None, trials=None, handle_argv= if hasattr(django, 'setup'): django.setup() if migrate: - from django.core.management import call_command + from django.core.management import CommandError, call_command if django.VERSION < (1, 7): call_command("syncdb", run_syncdb=True, verbosity=0) else: call_command("migrate", run_syncdb=True, verbosity=0) if django.VERSION >= (1, 8): - call_command("loaddata", "initial_data", verbosity=0) + try: + call_command("loaddata", "initial_data", verbosity=0) + except CommandError as exc: + # Django 1.10+ raises if the file doesn't exist and not + # all benchmarks have files. + if 'No fixture named' not in str(exc): + raise if setup: setup()