From f9e17dba1ae97c48203fc5cc45798a06df4bb0d9 Mon Sep 17 00:00:00 2001 From: pzinovkin Date: Sun, 9 Oct 2011 10:02:51 +0400 Subject: [PATCH] Fix for error 'Settings' object has no attribute 'DATABASE_ENGINE' --- debug_toolbar/views.py | 5 ++++- runtests.py | 16 +++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/debug_toolbar/views.py b/debug_toolbar/views.py index e0c80aad4..dd9916b79 100644 --- a/debug_toolbar/views.py +++ b/debug_toolbar/views.py @@ -82,7 +82,10 @@ def sql_explain(request): params = simplejson.loads(params) cursor = connections[alias].cursor() - if settings.DATABASE_ENGINE == "sqlite3": + conn = connections[alias].connection + engine = conn.__class__.__module__.split('.', 1)[0] + + if engine == "sqlite3": # SQLite's EXPLAIN dumps the low-level opcodes generated for a query; # EXPLAIN QUERY PLAN dumps a more human-readable summary # See http://www.sqlite.org/lang_explain.html for details diff --git a/runtests.py b/runtests.py index dc5f6d09e..ec71a577b 100644 --- a/runtests.py +++ b/runtests.py @@ -7,10 +7,11 @@ if not settings.configured: settings.configure( - DATABASE_ENGINE='sqlite3', - # HACK: this fixes our threaded runserver remote tests - # DATABASE_NAME='test_sentry', - # TEST_DATABASE_NAME='test_sentry', + DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + } + }, INSTALLED_APPS=[ 'django.contrib.auth', 'django.contrib.admin', @@ -30,7 +31,7 @@ SITE_ID=1, ) -from django.test.simple import run_tests +from django.test.simple import DjangoTestSuiteRunner def runtests(*test_args, **kwargs): if 'south' in settings.INSTALLED_APPS: @@ -41,7 +42,8 @@ def runtests(*test_args, **kwargs): test_args = ['tests'] parent = dirname(abspath(__file__)) sys.path.insert(0, parent) - failures = run_tests(test_args, verbosity=kwargs.get('verbosity', 1), interactive=kwargs.get('interactive', False), failfast=kwargs.get('failfast')) + test_runner = DjangoTestSuiteRunner(verbosity=kwargs.get('verbosity', 1), interactive=kwargs.get('interactive', False), failfast=kwargs.get('failfast')) + failures = test_runner.run_tests(test_args) sys.exit(failures) if __name__ == '__main__': @@ -50,4 +52,4 @@ def runtests(*test_args, **kwargs): (options, args) = parser.parse_args() - runtests(failfast=options.failfast, *args) \ No newline at end of file + runtests(failfast=options.failfast, *args)