summaryrefslogtreecommitdiff
path: root/tests/regressiontests/middleware_exceptions
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2010-03-12 16:45:29 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2010-03-12 16:45:29 +0000
commit794690c272fd7e9ee00242980e461214fcd80fcf (patch)
tree895031b8ed6cc830d5b17b4a3a7e0b3d9e7b1f51 /tests/regressiontests/middleware_exceptions
parent4120a181e9109383ab35df52dbb3621302a75a72 (diff)
Fixed #13090 -- Corrected handling of errors in middleware when DEBUG=False. Thanks to EroSennin for the report, and Ivan Sagalaev for the patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12773 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/middleware_exceptions')
-rw-r--r--tests/regressiontests/middleware_exceptions/tests.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/tests/regressiontests/middleware_exceptions/tests.py b/tests/regressiontests/middleware_exceptions/tests.py
index 00c7d8b59f..3d9c5f6e83 100644
--- a/tests/regressiontests/middleware_exceptions/tests.py
+++ b/tests/regressiontests/middleware_exceptions/tests.py
@@ -3,9 +3,12 @@ import sys
from django.test import TestCase
from django.core.signals import got_request_exception
-class RequestMiddleware(object):
+class TestException(Exception):
+ pass
+
+class TestMiddleware(object):
def process_request(self, request):
- raise Exception('Exception')
+ raise TestException('Test Exception')
class MiddlewareExceptionTest(TestCase):
def setUp(self):
@@ -21,15 +24,17 @@ class MiddlewareExceptionTest(TestCase):
self.exceptions.append(sys.exc_info())
def test_process_request(self):
- self.client.handler._request_middleware.insert(0, RequestMiddleware().process_request)
+ self.client.handler._request_middleware.insert(0, TestMiddleware().process_request)
try:
response = self.client.get('/')
- except:
+ except TestException, e:
# Test client indefinitely re-raises any exceptions being raised
# during request handling. Hence actual testing that exception was
# properly handled is done by relying on got_request_exception
# signal being sent.
pass
+ except Exception, e:
+ self.fail("Unexpected exception: %s" % e)
self.assertEquals(len(self.exceptions), 1)
exception, value, tb = self.exceptions[0]
- self.assertEquals(value.args, ('Exception', ))
+ self.assertEquals(value.args, ('Test Exception', ))