diff options
| author | Vladislav Poluhin | 2013-04-24 15:54:17 +0800 |
|---|---|---|
| committer | Vladislav Poluhin | 2013-04-24 15:54:17 +0800 |
| commit | 4c1c4f7a8873a80f843ba683240b9d0ff0f49e4b (patch) | |
| tree | 4840de7ec2ec41d1ef7cc362803c2d0ace58d663 /tests/tests.py | |
| parent | 3d0467d9a4394c4b994a802e6e861ff2562dbb2b (diff) | |
| parent | 6f79f0b0ada69e1d95d97066ba78e0d18aeab3ba (diff) | |
| download | django-debug-toolbar-4c1c4f7a8873a80f843ba683240b9d0ff0f49e4b.tar.bz2 | |
Merge branch 'master' of https://github.com/django-debug-toolbar/django-debug-toolbar into sql-panel-refactor
Conflicts:
debug_toolbar/static/debug_toolbar/css/toolbar.min.css
debug_toolbar/views.py
Diffstat (limited to 'tests/tests.py')
| -rw-r--r-- | tests/tests.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/tests.py b/tests/tests.py index ea2938d..f76f1ab 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -1,10 +1,13 @@ +from __future__ import with_statement 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 +217,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) |
