aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--debug_toolbar/management/commands/debugsqlshell.py9
-rw-r--r--tests/commands/test_debugsqlshell.py11
-rw-r--r--tests/panels/test_logging.py4
-rw-r--r--tests/settings.py2
4 files changed, 18 insertions, 8 deletions
diff --git a/debug_toolbar/management/commands/debugsqlshell.py b/debug_toolbar/management/commands/debugsqlshell.py
index 2d4bfa6..7e1471f 100644
--- a/debug_toolbar/management/commands/debugsqlshell.py
+++ b/debug_toolbar/management/commands/debugsqlshell.py
@@ -4,12 +4,15 @@ from time import time
# 'debugsqlshell' is the same as the 'shell'.
from django.core.management.commands.shell import Command # noqa
-from django.db.backends import util
+try:
+ from django.db.backends import utils
+except ImportError:
+ from django.db.backends import util as utils
import sqlparse
-class PrintQueryWrapper(util.CursorDebugWrapper):
+class PrintQueryWrapper(utils.CursorDebugWrapper):
def execute(self, sql, params=()):
start_time = time()
try:
@@ -22,4 +25,4 @@ class PrintQueryWrapper(util.CursorDebugWrapper):
print('%s [%.2fms]' % (formatted_sql, duration))
-util.CursorDebugWrapper = PrintQueryWrapper
+utils.CursorDebugWrapper = PrintQueryWrapper
diff --git a/tests/commands/test_debugsqlshell.py b/tests/commands/test_debugsqlshell.py
index f0c88fa..f10a629 100644
--- a/tests/commands/test_debugsqlshell.py
+++ b/tests/commands/test_debugsqlshell.py
@@ -4,7 +4,10 @@ import sys
from django.contrib.auth.models import User
from django.core import management
-from django.db.backends import util
+try:
+ from django.db.backends import utils
+except ImportError:
+ from django.db.backends import util as utils
from django.test import TestCase
from django.test.utils import override_settings
from django.utils import six
@@ -14,8 +17,8 @@ from django.utils import six
class DebugSQLShellTestCase(TestCase):
def setUp(self):
- self.original_cursor_wrapper = util.CursorDebugWrapper
- # Since debugsqlshell monkey-patches django.db.backends.util, we can
+ self.original_cursor_wrapper = utils.CursorDebugWrapper
+ # Since debugsqlshell monkey-patches django.db.backends.utils, we can
# test it simply by loading it, without executing it. But we have to
# undo the monkey-patch on exit.
command_name = 'debugsqlshell'
@@ -23,7 +26,7 @@ class DebugSQLShellTestCase(TestCase):
management.load_command_class(app_name, command_name)
def tearDown(self):
- util.CursorDebugWrapper = self.original_cursor_wrapper
+ utils.CursorDebugWrapper = self.original_cursor_wrapper
def test_command(self):
original_stdout, sys.stdout = sys.stdout, six.StringIO()
diff --git a/tests/panels/test_logging.py b/tests/panels/test_logging.py
index 342e673..288efad 100644
--- a/tests/panels/test_logging.py
+++ b/tests/panels/test_logging.py
@@ -2,7 +2,8 @@ from __future__ import absolute_import, unicode_literals
import logging
-from debug_toolbar.panels.logging import MESSAGE_IF_STRING_REPRESENTATION_INVALID
+from debug_toolbar.panels.logging import (
+ collector, MESSAGE_IF_STRING_REPRESENTATION_INVALID)
from ..base import BaseTestCase
@@ -13,6 +14,7 @@ class LoggingPanelTestCase(BaseTestCase):
super(LoggingPanelTestCase, self).setUp()
self.panel = self.toolbar.get_panel_by_id('LoggingPanel')
self.logger = logging.getLogger(__name__)
+ collector.clear_collection()
def test_happy_case(self):
self.logger.info('Nothing to see here, move along!')
diff --git a/tests/settings.py b/tests/settings.py
index 70049b4..0a4094d 100644
--- a/tests/settings.py
+++ b/tests/settings.py
@@ -40,6 +40,8 @@ MIDDLEWARE_CLASSES = [
ROOT_URLCONF = 'tests.urls'
+STATIC_ROOT = os.path.join(BASE_DIR, 'tests', 'static')
+
STATIC_URL = '/static/'
STATICFILES_DIRS = [