From 54f4f3a7361ae711641b511df5a4c8962ad623a4 Mon Sep 17 00:00:00 2001 From: Anssi Kääriäinen Date: Mon, 27 Aug 2012 14:22:25 +0300 Subject: Tests for issue_230 --- tests/tests.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests') diff --git a/tests/tests.py b/tests/tests.py index ea2938d..a3618bf 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -2,9 +2,11 @@ import thread from django.conf import settings from django.contrib.auth.models import User +from django.db import connection from django.http import HttpResponse from django.test import TestCase, RequestFactory from django.template import Template, Context +from django.utils import unittest from debug_toolbar.middleware import DebugToolbarMiddleware from debug_toolbar.panels.sql import SQLDebugPanel @@ -214,6 +216,19 @@ class SQLPanelTestCase(BaseTestCase): # ensure the stacktrace is populated self.assertTrue(len(query[1]['stacktrace']) > 0) + @unittest.skipUnless(connection.vendor=='postgresql', + 'Test valid only on PostgreSQL') + def test_erroneous_query(self): + """ + Test that an error in the query isn't swallowed by the middleware. + """ + from django.db import connection + from django.db.utils import DatabaseError + try: + connection.cursor().execute("erroneous query") + except DatabaseError as e: + self.assertTrue('erroneous query' in str(e)) + def test_disable_stacktraces(self): panel = self.toolbar.get_panel(SQLDebugPanel) self.assertEquals(len(panel._queries), 0) -- cgit v1.2.3 From 3013b5a6e4c682004207e944ebea172a39e52e8c Mon Sep 17 00:00:00 2001 From: David Buxton Date: Tue, 11 Dec 2012 11:36:25 +0000 Subject: Python 2.5 compatibility #261 --- tests/tests.py | 1 + 1 file changed, 1 insertion(+) (limited to 'tests') diff --git a/tests/tests.py b/tests/tests.py index ea2938d..678a8fc 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -1,3 +1,4 @@ +from __future__ import with_statement import thread from django.conf import settings -- cgit v1.2.3 From 39088e7cabfba63201ac4b1e27b8410d455ccc46 Mon Sep 17 00:00:00 2001 From: Simon Charette Date: Sun, 30 Dec 2012 02:22:44 -0500 Subject: Avoid importing `django.conf.urls.defaults` on django 1.4+ --- tests/urls.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/urls.py b/tests/urls.py index a556703..778f417 100644 --- a/tests/urls.py +++ b/tests/urls.py @@ -4,14 +4,17 @@ URLpatterns for the debug toolbar. These should not be loaded explicitly; the debug toolbar middleware will patch this into the urlconf for the request. """ -from django.conf.urls.defaults import * from django.contrib import admin +try: + from django.conf.urls import patterns, url +except ImportError: # django < 1.4 + from django.conf.urls.defaults import patterns, url admin.autodiscover() urlpatterns = patterns('', # This pattern should be last to ensure tests still work - url(r'^resolving1/(.+)/(.+)/$', 'tests.views.resolving_view', name = 'positional-resolving'), + url(r'^resolving1/(.+)/(.+)/$', 'tests.views.resolving_view', name='positional-resolving'), url(r'^resolving2/(?P.+)/(?P.+)/$', 'tests.views.resolving_view'), url(r'^resolving3/(.+)/$', 'tests.views.resolving_view', { 'arg2' : 'default' }), url(r'^execute_sql/$', 'tests.views.execute_sql'), -- cgit v1.2.3